Class SubsetService

java.lang.Object
io.skipcheck.tm1.client.service.dimension.SubsetService

public final class SubsetService extends Object
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(String, String, SubsetScope, String, SubsetPatch) refuses it: addElements(String, String, SubsetScope, String, List) appends by name and clearElements(String, String, SubsetScope, String) 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);
  • Constructor Details

    • SubsetService

      public SubsetService(Tm1Session session)
      A service sending its requests through session.
      Parameters:
      session - the session
  • Method Details

    • list

      @Tm1Endpoint("Navigation Hierarchy/Subsets") @Tm1Endpoint("Navigation Hierarchy/PrivateSubsets") @Tm1Endpoint("Navigation Hierarchy/SessionSubsets") public reactor.core.publisher.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(String, String, SubsetPatch) 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

      @Tm1Endpoint("Navigation Hierarchy/Subsets") @Tm1Endpoint("Navigation Hierarchy/PrivateSubsets") @Tm1Endpoint("Navigation Hierarchy/SessionSubsets") public reactor.core.publisher.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

      @Tm1Endpoint("Navigation Hierarchy/Subsets") @Tm1Endpoint("Navigation Hierarchy/PrivateSubsets") @Tm1Endpoint("Navigation Hierarchy/SessionSubsets") public reactor.core.publisher.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

      @Tm1Endpoint("Navigation Hierarchy/Subsets") @Tm1Endpoint("Navigation Hierarchy/PrivateSubsets") @Tm1Endpoint("Navigation Hierarchy/SessionSubsets") public reactor.core.publisher.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(String, String, SubsetScope, String, List) or clearElements(String, String, SubsetScope, String)
    • update

      @Tm1Endpoint("Navigation Hierarchy/Subsets") @Tm1Endpoint("Navigation Hierarchy/PrivateSubsets") @Tm1Endpoint("Navigation Hierarchy/SessionSubsets") public reactor.core.publisher.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

      @Tm1Endpoint("Navigation Hierarchy/Subsets") @Tm1Endpoint("Navigation Hierarchy/PrivateSubsets") @Tm1Endpoint("Navigation Hierarchy/SessionSubsets") public reactor.core.publisher.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

      @Tm1Endpoint("Navigation Subset/Elements") public reactor.core.publisher.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
    • delete

      @Tm1Endpoint("Navigation Hierarchy/Subsets") @Tm1Endpoint("Navigation Hierarchy/PrivateSubsets") @Tm1Endpoint("Navigation Hierarchy/SessionSubsets") public reactor.core.publisher.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

      @Tm1Endpoint("Navigation Subset/Elements") public reactor.core.publisher.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
    • hierarchy

      @Tm1Endpoint("Navigation Subset/Hierarchy") public reactor.core.publisher.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
    • saveAs

      @Tm1Endpoint("Action Subset/SaveAs") public reactor.core.publisher.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
    • saveAs

      @Tm1Endpoint("Action Subset/SaveAs") public reactor.core.publisher.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
    • setElement

      @Tm1Endpoint("Action Subset/SetElement") public reactor.core.publisher.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
    • setElementBefore

      @Tm1Endpoint("Action Subset/SetElement") public reactor.core.publisher.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
    • setElementAfter

      @Tm1Endpoint("Action Subset/SetElement") public reactor.core.publisher.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
    • createSessionSubset

      @Tm1Endpoint("Action Hierarchy/CreateSessionSubset") public reactor.core.publisher.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
    • createSessionSubsetFrom

      @Tm1Endpoint("Action Hierarchy/CreateSessionSubset") public reactor.core.publisher.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