HierarchyService
import { HierarchyService } from "@skipcheck/tm1-client"; Hierarchies: /Dimensions('d')/Hierarchies, a dimension's default hierarchy, and
the operations bound to a hierarchy. Elements, edges, members, levels and subsets have
services of their own.
A hierarchy PATCH that sets Elements or Edges replaces them:
TM1 deletes the elements it doesn't list. So update refuses such a patch, and
replaceStructure does it by name.
Add a hierarchy to a dimension, with its elements and edges:
// A second hierarchy of Region, rolling the same leaves up by manager
const byManager = HierarchyPatch.builder()
.name("By Manager")
.elements([
ElementPatch.builder().name("Smith").type(ElementType.Consolidated).build(),
ElementPatch.builder().name("North").type(ElementType.Numeric).build(),
ElementPatch.builder().name("South").type(ElementType.Numeric).build(),
])
.edges([
EdgePatch.builder().parentName("Smith").componentName("North").weight(1).build(),
EdgePatch.builder().parentName("Smith").componentName("South").weight(1).build(),
])
.build();
return tm1.hierarchies.create("Region", byManager);
Replace a hierarchy's structure, knowing that TM1 deletes what isn't listed:
// Makes the elements and edges exactly these: TM1 deletes every other element of the
// hierarchy, with its data
const all = ElementPatch.builder().name("All Versions").type(ElementType.Consolidated).build();
const actual = ElementPatch.builder().name("Actual").type(ElementType.Numeric).build();
const budget = ElementPatch.builder().name("Budget").type(ElementType.Numeric).build();
return tm1.hierarchies.replaceStructure(
"Version",
"Version",
[all, actual, budget],
[
EdgePatch.builder().parentName("All Versions").componentName("Actual").weight(1).build(),
EdgePatch.builder().parentName("All Versions").componentName("Budget").weight(1).build(),
],
);
Read the roots of a hierarchy:
// The top of the hierarchy: the members with no parent, in order
const members = await tm1.hierarchies.rootMembers("Region", "Region", ODataQuery.none().select(Member.Fields.Name)).toArray();
return members.map((member) => member.Name!);
Members
list | The dimension's hierarchies, streamed. |
get | The hierarchy, or a Tm1NotFoundException if there's none. |
create | Adds a hierarchy, with its elements and edges if the patch has them. |
update | Changes the properties the patch sets. |
replaceStructure | PATCH Dimensions('d')/Hierarchies('h') with Elements and Edges. |
delete | DELETE Dimensions('d')/Hierarchies('h'). |
defaultHierarchy | The dimension's default hierarchy. |
dimension | The hierarchy's dimension. |
allMember | The member that stands for the whole hierarchy. |
defaultMember | The default member; null if TM1 sends no content. |
rootMembers | The members with no parent, streamed. |
saveAs | Copies a hierarchy under a new name in the same dimension, failing if one exists; returns the copy. |
saveAs | Copies a hierarchy under a new name in the same dimension; overwrite replaces a hierarchy that already has it, and keepExistingAttributes, when overwriting, keeps the attributes of what's replaced (when not, true creates no attributes for the copy). |
saveAs | |
setElement | Makes an element a root of the hierarchy, placed just before the root before, or, without it, *last* among the roots. |
list
list(dimension: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Hierarchy>GET Dimensions('d')/Hierarchies: the dimension's hierarchies, streamed.
TM1 REST Navigation Dimension/Hierarchies
get
get(dimension: string, hierarchy: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Hierarchy>GET Dimensions('d')/Hierarchies('h'): the hierarchy, or a Tm1NotFoundException if there's none.
TM1 REST Navigation Dimension/Hierarchies
create
create(dimension: string, hierarchy: HierarchyPatch, options?: Tm1CallOptions): Promise<Hierarchy>POST Dimensions('d')/Hierarchies: adds a hierarchy, with its elements and edges if the patch has them. It needs a name; returns the hierarchy as created.
TM1 REST Navigation Dimension/Hierarchies
update
update(dimension: string, hierarchy: string, patch: HierarchyPatch, etag?: string | null, options?: Tm1CallOptions): Promise<void>PATCH Dimensions('d')/Hierarchies('h'): changes the properties the patch sets. TM1 (11.8) ignores Visible. With etag (hierarchy["@odata.etag"], from a read), sent as If-Match: only if the hierarchy hasn't changed since, else a Tm1PreconditionFailedException.
Throws a RangeError at once if the patch sets Elements or Edges (or binds them), which would replace them: use replaceStructure.
TM1 REST Navigation Dimension/Hierarchies
replaceStructure
replaceStructure( dimension: string, hierarchy: string, elements: readonly ElementPatch[], edges: readonly EdgePatch[], options?: Tm1CallOptions, ): Promise<void>PATCH Dimensions('d')/Hierarchies('h') with Elements and Edges: makes them exactly these. TM1 deletes every element not listed, with its data.
TM1 REST Navigation Dimension/Hierarchies
delete
delete(dimension: string, hierarchy: string, options?: Tm1CallOptions): Promise<void>DELETE Dimensions('d')/Hierarchies('h').
TM1 REST Navigation Dimension/Hierarchies
defaultHierarchy
defaultHierarchy(dimension: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Hierarchy>GET Dimensions('d')/DefaultHierarchy: the dimension's default hierarchy.
TM1 REST Navigation Dimension/DefaultHierarchy
dimension
dimension(dimension: string, hierarchy: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Dimension>GET Dimensions('d')/Hierarchies('h')/Dimension: the hierarchy's dimension.
TM1 REST Navigation Hierarchy/Dimension
allMember
allMember(dimension: string, hierarchy: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Member | null>GET Dimensions('d')/Hierarchies('h')/AllMember: the member that stands for the whole hierarchy. TM1 (11.8) has one only when the hierarchy has a single root, which is then that root; with several roots it sends no content, and this is null.
TM1 REST Navigation Hierarchy/AllMember
defaultMember
defaultMember(dimension: string, hierarchy: string, query?: ODataQuery | null, options?: Tm1CallOptions): Promise<Member | null>GET Dimensions('d')/Hierarchies('h')/DefaultMember: the default member; null if TM1 sends no content.
TM1 REST Navigation Hierarchy/DefaultMember
rootMembers
rootMembers(dimension: string, hierarchy: string, query?: ODataQuery | null, options?: Tm1CallOptions): Tm1Stream<Member>tm1.RootMembers(): the members with no parent, streamed. Needs schema 11.4.7.
TM1 REST Function Hierarchy/RootMembers
saveAs
saveAs(dimension: string, hierarchy: string, newName: string, options?: Tm1CallOptions): Promise<Hierarchy>tm1.SaveAs: copies a hierarchy under a new name in the same dimension, failing if one exists; returns the copy.
TM1 REST Action Hierarchy/SaveAs
saveAs
saveAs( dimension: string, hierarchy: string, newName: string, overwrite: boolean, keepExistingAttributes: boolean, options?: Tm1CallOptions, ): Promise<Hierarchy>tm1.SaveAs: copies a hierarchy under a new name in the same dimension; overwrite replaces a hierarchy that already has it, and keepExistingAttributes, when overwriting, keeps the attributes of what's replaced (when not, true creates no attributes for the copy).
TM1 REST Action Hierarchy/SaveAs
saveAs
saveAs( dimension: string, hierarchy: string, newName: string, overwrite?: boolean | Tm1CallOptions, keepExistingAttributes?: boolean, options?: Tm1CallOptions, ): Promise<Hierarchy>TM1 REST Action Hierarchy/SaveAs
setElement
setElement(dimension: string, hierarchy: string, element: string, before?: string | null, options?: Tm1CallOptions): Promise<void>tm1.SetElement: makes an element a root of the hierarchy, placed just before the root before, or, without it, *last* among the roots. ($metadata says first; TM1 11.8 puts it last.)
TM1 REST Action Hierarchy/SetElement