skipcheck

TM1 client · Docs · Reading and writing data

MemberSetService

import io.skipcheck.tm1.client.service.data.MemberSetService;

Member sets: the results of MDX set expressions, as a single axis of tuples, kept on the server in /MemberSets and keyed by an ordinal TM1 assigns (1, 2, … in the session).

Like a cellset, a member set stays until it's deleted or the session ends. TM1 (11.8) lists none, though each reads by its ordinal: keep the ordinals execute returns, and delete what you're done with.

Evaluate a set expression and read its members' names, deleting the set after:

// The names of Region's leaves, with the member set deleted once they're read
return Flux.usingWhen(
        tm1.memberSets()
            .execute("{TM1FILTERBYLEVEL({TM1SUBSETALL([Region].[Region])}, 0)}",
                    ODataQuery.none()
                        .expand(CellsetAxis.TUPLES, t -> t.expand("Members", m -> m.select(Member.NAME)))),
        set -> Flux.fromIterable(set.tuples()).map(tuple -> tuple.members().get(0).name()),
        set -> tm1.memberSets().delete(set.ordinal()));

Keep a set on the server to read later, by the ordinal TM1 gives it:

// Keep a large set on the server and read it later by its ordinal; TM1 doesn't
// list member sets, so hold on to the ordinal, and delete the set when done
return tm1.memberSets()
    .execute("{TM1SUBSETALL([Product].[Product])}", ODataQuery.none())
    .map(CellsetAxis::ordinal);

Members

MemberSetService constructorA service sending its requests through session.
executeEvaluates an MDX set expression, such as {TM1SUBSETALL([Region].[Region])}, keeping the result as a member set.
listGET MemberSets, streamed.
getGET MemberSets(n).
deleteFrees the set on the server.

MemberSetService

constructor
MemberSetService(Tm1Session session)

A service sending its requests through session.

Parameters

session
the session

execute

Mono<CellsetAxis> execute(String mdx, ODataQuery query)

ExecuteMDXSetExpression: evaluates an MDX set expression, such as {TM1SUBSETALL([Region].[Region])}, keeping the result as a member set. Expand Tuples($expand=Members($select=Name)) to get its members in the same round trip. Needs schema 11.1.0.

Parameters

mdx
the set expression
query
what to expand of the result

Returns

the set, with the Ordinal that keys it in MemberSets

TM1 REST ActionImport ExecuteMDXSetExpression

list

Flux<CellsetAxis> list(ODataQuery query)

GET MemberSets, streamed. TM1 (11.8) lists none, though each reads by its ordinal with get.

Parameters

query
what to select and expand

Returns

the member sets TM1 lists

TM1 REST EntitySet MemberSets

get

Mono<CellsetAxis> get(int ordinal, ODataQuery query)

GET MemberSets(n).

Parameters

ordinal
the set's ordinal, from execute
query
what to expand, such as Tuples($expand=Members)

Returns

the set, or a Tm1NotFoundException if it's gone

TM1 REST EntitySet MemberSets

delete

Mono<Void> delete(int ordinal)

DELETE MemberSets(n): frees the set on the server.

Parameters

ordinal
the set's ordinal

Returns

completes when it's deleted

TM1 REST EntitySet MemberSets

Also in the Javadoc.