skipcheck

TM1 client · Docs · Dimensions and hierarchies

SubsetService

import io.skipcheck.tm1.client.service.dimension.SubsetService;

Subsets: a hierarchy's public, private and session subsets (SubsetScope), their elements, and the operations bound to a subset or creating a session subset.

A static subset lists its elements; a dynamic one has an MDX Expression. Binding Elements in a subset PATCH appends to them, so update refuses it: addElements appends by name and clearElements empties the list.

Create a static subset, binding its elements:

// A static subset lists its elements, bound by their paths
ODataPath elements = ODataPath.of("Dimensions").key("Region").nav("Hierarchies").key("Region").nav("Elements");
return tm1.subsets()
    .create("Region", "Region", SubsetScope.PUBLIC,
            SubsetPatch.builder()
                .name("Key Regions")
                .bindElements(elements.key("North"), elements.key("South"))
                .build());

Create a dynamic subset from an MDX expression:

// A dynamic subset has an MDX expression, evaluated each time it's read
return tm1.subsets()
    .create("Region", "Region", SubsetScope.PUBLIC,
            SubsetPatch.builder()
                .name("All Leaves")
                .expression("{TM1FILTERBYLEVEL({TM1SUBSETALL([Region].[Region])}, 0)}")
                .build());

Replace a static subset's elements:

// A PATCH appends elements, so empty the list, then add the new ones in order
return tm1.subsets()
    .clearElements("Region", "Region", SubsetScope.PUBLIC, "Key Regions")
    .then(tm1.subsets()
        .addElements("Region", "Region", SubsetScope.PUBLIC, "Key Regions", List.of("East", "West")));

Create a session subset and read its elements by the name TM1 gave it:

// TM1 names a session subset itself, ignoring the name sent: read it by the name
// it gives back
return tm1.subsets()
    .createSessionSubset("Region", "Region",
            SubsetPatch.builder().name("Regions").expression("{[Region].[Region].[Total].Children}").build())
    .flatMapMany(subset -> tm1.subsets()
        .elements("Region", "Region", SubsetScope.SESSION, subset.name(),
                ODataQuery.none().select(Element.NAME)))
    .map(Element::name);

Members

SubsetService constructorA service sending its requests through session.
listGET …/Hierarchies('h')/Subsets (or the private or session ones), streamed.
getGET …/Subsets('s').
createCreates a subset.
updateChanges the properties the patch sets, such as a dynamic subset's expression.
updatePATCH …/Subsets('s') with If-Match.
addElementsPATCH …/Subsets('s') binding Elements.
clearElementsRemoves every element from a static subset; the elements stay in the hierarchy.
deleteDELETE …/Subsets('s').
elementsGET …/Subsets('s')/Elements, streamed.
hierarchyGET …/Subsets('s')/Hierarchy.
saveAsCopies a subset under a new name, as public and keeping whether it's static or dynamic.
saveAsCopies a subset under a new name.
setElementAdds an element to a static subset, or moves it if it's there.
setElementBeforetm1.SetElement with Before.
setElementAftertm1.SetElement with After.
createSessionSubsettm1.CreateSessionSubset with a definition.
createSessionSubsetFromtm1.CreateSessionSubset with a reference.

SubsetService

constructor
SubsetService(Tm1Session session)

A service sending its requests through session.

Parameters

session
the session

list

Flux<Subset> list(String dimension, String hierarchy, SubsetScope scope, ODataQuery query)

GET …/Hierarchies('h')/Subsets (or the private or session ones), streamed. TM1 (11.8) lists no session subsets, though each reads by the name createSessionSubset returned.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
which subsets
query
what to select, expand, filter and order

Returns

the subsets

get

Mono<Subset> get(String dimension, String hierarchy, SubsetScope scope, String subset, ODataQuery query)

GET …/Subsets('s').

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
query
what to select and expand

Returns

the subset, or a Tm1NotFoundException if there's none

create

Mono<Subset> create(String dimension, String hierarchy, SubsetScope scope, SubsetPatch subset)

POST …/Subsets: creates a subset: static with Elements@odata.bind (SubsetPatch.Builder#bindElements), dynamic with an Expression.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where to create it
subset
the new subset; it needs a name

Returns

the subset as created

update

Mono<Void> update(String dimension, String hierarchy, SubsetScope scope, String subset, SubsetPatch patch)

PATCH …/Subsets('s'): changes the properties the patch sets, such as a dynamic subset's expression.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
patch
the changes, without Elements

Returns

completes when the subset is changed

Throws

IllegalArgumentException
if the patch sets or binds Elements, which TM1 appends: use addElements or clearElements

update

Mono<Void> update(String dimension, String hierarchy, SubsetScope scope, String subset, SubsetPatch patch, String etag)

PATCH …/Subsets('s') with If-Match.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
patch
the changes, without Elements
etag
the ETag the subset was read with (Subset.etag)

Returns

completes when the subset is changed, or a Tm1PreconditionFailedException if it had changed

Throws

IllegalArgumentException
if the patch sets or binds Elements

addElements

Mono<Void> addElements(String dimension, String hierarchy, SubsetScope scope, String subset, List<String> elements)

PATCH …/Subsets('s') binding Elements: appends elements to a static subset, in order.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
elements
the names of the elements to append

Returns

completes when they're added

clearElements

Mono<Void> clearElements(String dimension, String hierarchy, SubsetScope scope, String subset)

DELETE …/Subsets('s')/Elements/$ref: removes every element from a static subset; the elements stay in the hierarchy.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name

Returns

completes when the subset is empty

TM1 REST Navigation Subset/Elements

delete

Mono<Void> delete(String dimension, String hierarchy, SubsetScope scope, String subset)

DELETE …/Subsets('s').

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name

Returns

completes when the subset is deleted

elements

Flux<Element> elements(String dimension, String hierarchy, SubsetScope scope, String subset, ODataQuery query)

GET …/Subsets('s')/Elements, streamed: a static subset's elements in order, or what a dynamic one's expression gives now.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
query
what to select, expand and filter of each element

Returns

the subset's elements

TM1 REST Navigation Subset/Elements

hierarchy

Mono<Hierarchy> hierarchy(String dimension, String hierarchy, SubsetScope scope, String subset, ODataQuery query)

GET …/Subsets('s')/Hierarchy.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
query
what to select and expand

Returns

the subset's hierarchy

TM1 REST Navigation Subset/Hierarchy

saveAs

Mono<Subset> saveAs(String dimension, String hierarchy, SubsetScope scope, String subset, String newName)

tm1.SaveAs: copies a subset under a new name, as public and keeping whether it's static or dynamic.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
newName
the copy's name

Returns

the copy

TM1 REST Action Subset/SaveAs

saveAs

Mono<Subset> saveAs(String dimension, String hierarchy, SubsetScope scope, String subset, String newName, boolean makePrivate, boolean makeStatic)

tm1.SaveAs: copies a subset under a new name.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
newName
the copy's name
makePrivate
whether the copy is private
makeStatic
whether the copy is static, holding the elements the subset has now

Returns

the copy

TM1 REST Action Subset/SaveAs

setElement

Mono<Void> setElement(String dimension, String hierarchy, SubsetScope scope, String subset, String element)

tm1.SetElement: adds an element to a static subset, or moves it if it's there.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
element
the element's name

Returns

completes when the element is placed

TM1 REST Action Subset/SetElement

setElementBefore

Mono<Void> setElementBefore(String dimension, String hierarchy, SubsetScope scope, String subset, String element, String before)

tm1.SetElement with Before: places an element just before another in a static subset.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
element
the element's name
before
the name of the element to place it before

Returns

completes when the element is placed

TM1 REST Action Subset/SetElement

setElementAfter

Mono<Void> setElementAfter(String dimension, String hierarchy, SubsetScope scope, String subset, String element, String after)

tm1.SetElement with After: places an element just after another in a static subset.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset is
subset
the subset's name
element
the element's name
after
the name of the element to place it after

Returns

completes when the element is placed

TM1 REST Action Subset/SetElement

createSessionSubset

Mono<Subset> createSessionSubset(String dimension, String hierarchy, SubsetPatch definition)

tm1.CreateSessionSubset with a definition: creates a subset visible only to this session. TM1 (11.8) ignores the definition's Name and names it itself; the result has the name to use.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
definition
the subset: an Expression, or bound Elements

Returns

the session subset, with the name TM1 gave it

TM1 REST Action Hierarchy/CreateSessionSubset

createSessionSubsetFrom

Mono<Subset> createSessionSubsetFrom(String dimension, String hierarchy, SubsetScope scope, String subset)

tm1.CreateSessionSubset with a reference: copies a subset into one visible only to this session.

Parameters

dimension
the dimension's name
hierarchy
the hierarchy's name
scope
where the subset to copy is
subset
the name of the subset to copy

Returns

the session subset, with the name TM1 gave it

TM1 REST Action Hierarchy/CreateSessionSubset

Also in the Javadoc.