HierarchyService
import io.skipcheck.tm1.client.service.dimension.HierarchyService; 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
return tm1.hierarchies()
.create("Region", HierarchyPatch.builder()
.name("By Manager")
.elements(List.of(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(List.of(EdgePatch.builder().parentName("Smith").componentName("North").weight(1.0).build(),
EdgePatch.builder().parentName("Smith").componentName("South").weight(1.0).build()))
.build());
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
ElementPatch all = ElementPatch.builder().name("All Versions").type(ElementType.CONSOLIDATED).build();
ElementPatch actual = ElementPatch.builder().name("Actual").type(ElementType.NUMERIC).build();
ElementPatch budget = ElementPatch.builder().name("Budget").type(ElementType.NUMERIC).build();
return tm1.hierarchies()
.replaceStructure("Version", "Version", List.of(all, actual, budget), List.of(
EdgePatch.builder().parentName("All Versions").componentName("Actual").weight(1.0).build(),
EdgePatch.builder().parentName("All Versions").componentName("Budget").weight(1.0).build()));
Read the roots of a hierarchy:
// The top of the hierarchy: the members with no parent, in order
return tm1.hierarchies()
.rootMembers("Region", "Region", ODataQuery.none().select(Member.NAME))
.map(Member::name);
Members
HierarchyService constructor | A service sending its requests through session. |
list | GET Dimensions('d')/Hierarchies, streamed. |
get | GET Dimensions('d')/Hierarchies('h'). |
create | Adds a hierarchy, with its elements and edges if the patch has them. |
update | Changes the properties the patch sets. |
update | PATCH Dimensions('d')/Hierarchies('h') with If-Match. |
replaceStructure | PATCH Dimensions('d')/Hierarchies('h') with Elements and Edges. |
delete | DELETE Dimensions('d')/Hierarchies('h'). |
defaultHierarchy | GET Dimensions('d')/DefaultHierarchy. |
dimension | GET Dimensions('d')/Hierarchies('h')/Dimension. |
allMember | The member that stands for the whole hierarchy. |
defaultMember | GET Dimensions('d')/Hierarchies('h')/DefaultMember. |
rootMembers | The members with no parent, streamed. |
saveAs | Copies a hierarchy under a new name in the same dimension, failing if one exists. |
saveAs | Copies a hierarchy under a new name in the same dimension. |
setElement | tm1.SetElement with no Before. |
setElement | Makes an element a root of the hierarchy, placed just before another root. |
HierarchyService
constructorHierarchyService(Tm1Session session) A service sending its requests through session.
Parameters
session- the session
list
Flux<Hierarchy> list(String dimension, ODataQuery query) GET Dimensions('d')/Hierarchies, streamed.
Parameters
dimension- the dimension's name
query- what to select, expand, filter and order
Returns
- the dimension's hierarchies
TM1 REST Navigation Dimension/Hierarchies
get
Mono<Hierarchy> get(String dimension, String hierarchy, ODataQuery query) GET Dimensions('d')/Hierarchies('h').
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
query- what to select and expand
Returns
- the hierarchy, or a
Tm1NotFoundExceptionif there's none
TM1 REST Navigation Dimension/Hierarchies
create
Mono<Hierarchy> create(String dimension, HierarchyPatch hierarchy) POST Dimensions('d')/Hierarchies: adds a hierarchy, with its elements and
edges if the patch has them.
Parameters
dimension- the dimension's name
hierarchy- the new hierarchy; it needs a name
Returns
- the hierarchy as created
TM1 REST Navigation Dimension/Hierarchies
update
Mono<Void> update(String dimension, String hierarchy, HierarchyPatch patch) PATCH Dimensions('d')/Hierarchies('h'): changes the properties the patch
sets. TM1 (11.8) ignores Visible.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
patch- the changes, without
ElementsorEdges
Returns
- completes when the hierarchy is changed
Throws
IllegalArgumentException- if the patch sets
ElementsorEdges, which would replace them: usereplaceStructure
TM1 REST Navigation Dimension/Hierarchies
update
Mono<Void> update(String dimension, String hierarchy, HierarchyPatch patch, String etag) PATCH Dimensions('d')/Hierarchies('h') with If-Match: changes the
properties the patch sets, unless the hierarchy changed since it was read.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
patch- the changes, without
ElementsorEdges etag- the ETag the hierarchy was read with (
Hierarchy.etag)
Returns
- completes when the hierarchy is changed, or a
Tm1PreconditionFailedExceptionif it had changed
Throws
IllegalArgumentException- if the patch sets
ElementsorEdges: usereplaceStructure
TM1 REST Navigation Dimension/Hierarchies
replaceStructure
Mono<Void> replaceStructure(String dimension, String hierarchy, List<ElementPatch> elements, List<EdgePatch> edges) PATCH Dimensions('d')/Hierarchies('h') with Elements and
Edges: makes them exactly these. TM1 deletes every element not listed, with
its data.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
elements- every element the hierarchy should have
edges- every parent-child edge it should have
Returns
- completes when the hierarchy is replaced
TM1 REST Navigation Dimension/Hierarchies
delete
Mono<Void> delete(String dimension, String hierarchy) DELETE Dimensions('d')/Hierarchies('h').
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
Returns
- completes when the hierarchy is deleted
TM1 REST Navigation Dimension/Hierarchies
defaultHierarchy
Mono<Hierarchy> defaultHierarchy(String dimension, ODataQuery query) GET Dimensions('d')/DefaultHierarchy.
Parameters
dimension- the dimension's name
query- what to select and expand
Returns
- the dimension's default hierarchy
TM1 REST Navigation Dimension/DefaultHierarchy
dimension
Mono<Dimension> dimension(String dimension, String hierarchy, ODataQuery query) GET Dimensions('d')/Hierarchies('h')/Dimension.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
query- what to select and expand
Returns
- the hierarchy's dimension
TM1 REST Navigation Hierarchy/Dimension
allMember
Mono<Member> allMember(String dimension, String hierarchy, ODataQuery query) 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 completes
empty.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
query- what to select and expand
Returns
- the all member, or empty if the hierarchy has several roots
TM1 REST Navigation Hierarchy/AllMember
defaultMember
Mono<Member> defaultMember(String dimension, String hierarchy, ODataQuery query) GET Dimensions('d')/Hierarchies('h')/DefaultMember.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
query- what to select and expand
Returns
- the default member
TM1 REST Navigation Hierarchy/DefaultMember
rootMembers
Flux<Member> rootMembers(String dimension, String hierarchy, ODataQuery query) tm1.RootMembers(): the members with no parent, streamed. Needs schema
11.4.7.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
query- what to select and expand of each member
Returns
- the root members
TM1 REST Function Hierarchy/RootMembers
saveAs
Mono<Hierarchy> saveAs(String dimension, String hierarchy, String newName) tm1.SaveAs: copies a hierarchy under a new name in the same dimension,
failing if one exists.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
newName- the copy's name
Returns
- the copy
TM1 REST Action Hierarchy/SaveAs
saveAs
Mono<Hierarchy> saveAs(String dimension, String hierarchy, String newName, boolean overwrite, boolean keepExistingAttributes) tm1.SaveAs: copies a hierarchy under a new name in the same dimension.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
newName- the copy's name
overwrite- whether to replace a hierarchy that already has the new name
keepExistingAttributes- when overwriting, whether to keep the attributes of what's replaced; when not, true creates no attributes for the copy
Returns
- the copy
TM1 REST Action Hierarchy/SaveAs
setElement
Mono<Void> setElement(String dimension, String hierarchy, String element) tm1.SetElement with no Before: makes an element a root of the
hierarchy, placed last among the roots. ($metadata says first; TM1
11.8 puts it last.)
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
element- the element's name
Returns
- completes when the element is placed
TM1 REST Action Hierarchy/SetElement
setElement
Mono<Void> setElement(String dimension, String hierarchy, String element, String before) tm1.SetElement: makes an element a root of the hierarchy, placed just
before another root.
Parameters
dimension- the dimension's name
hierarchy- the hierarchy's name
element- the element's name
before- the name of the root to place it before
Returns
- completes when the element is placed
TM1 REST Action Hierarchy/SetElement
Also in the Javadoc.