Class ElementService

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

public final class ElementService extends Object
Elements: /Dimensions('d')/Hierarchies('h')/Elements, an element's parents, components and edges, and the operations bound to an element.

TM1 (11.8) ignores Name in an element PATCH, so elements can't be renamed, and rejects Attributes, whose values are cells of the }ElementAttributes_<dimension> cube. update(String, String, String, ElementPatch) refuses both, saying why.

List elements with a query: here, the consolidations.

// The names of the consolidated elements, in name order
return tm1.elements()
	.list("Region", "Region",
			ODataQuery.none()
				.select(Element.NAME)
				.filter(Element.TYPE.eq(ElementType.CONSOLIDATED))
				.orderBy(Element.NAME))
	.map(Element::name);

Add an element under a consolidation. A new element is a root until it has a parent:

// A new element is a root; SetComponent then puts it last under Total
return tm1.elements()
	.create("Region", "Region", ElementPatch.builder().name("West").type(ElementType.NUMERIC).build())
	.then(tm1.elements().setComponent("Region", "Region", "Total", "West"));

Read a consolidation's children:

// The children of Total, in order
return tm1.elements()
	.components("Region", "Region", "Total", ODataQuery.none().select(Element.NAME))
	.map(Element::name);
  • Constructor Details

    • ElementService

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

    • list

      @Tm1Endpoint("Navigation Hierarchy/Elements") public reactor.core.publisher.Flux<Element> list(String dimension, String hierarchy, ODataQuery query)
      GET …/Hierarchies('h')/Elements, streamed.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      query - what to select, expand, filter and order
      Returns:
      the hierarchy's elements
    • get

      @Tm1Endpoint("Navigation Hierarchy/Elements") public reactor.core.publisher.Mono<Element> get(String dimension, String hierarchy, String element, ODataQuery query)
      GET …/Elements('e').
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      query - what to select and expand
      Returns:
      the element, or a Tm1NotFoundException if there's none
    • create

      @Tm1Endpoint("Navigation Hierarchy/Elements") public reactor.core.publisher.Mono<Element> create(String dimension, String hierarchy, ElementPatch element)
      POST …/Elements: adds an element, as a root of the hierarchy.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the new element; it needs a name, and a type unless it's numeric
      Returns:
      the element as created
    • update

      @Tm1Endpoint("Navigation Hierarchy/Elements") public reactor.core.publisher.Mono<Void> update(String dimension, String hierarchy, String element, ElementPatch patch)
      PATCH …/Elements('e'): changes the properties the patch sets, such as its type.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      patch - the changes, without Name or Attributes
      Returns:
      completes when the element is changed
      Throws:
      IllegalArgumentException - if the patch sets Name, which TM1 ignores, or Attributes, which it rejects
    • update

      @Tm1Endpoint("Navigation Hierarchy/Elements") public reactor.core.publisher.Mono<Void> update(String dimension, String hierarchy, String element, ElementPatch patch, String etag)
      PATCH …/Elements('e') with If-Match.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      patch - the changes, without Name or Attributes
      etag - the ETag the element was read with (Element.etag())
      Returns:
      completes when the element is changed, or a Tm1PreconditionFailedException if it had changed
      Throws:
      IllegalArgumentException - if the patch sets Name or Attributes
    • delete

      @Tm1Endpoint("Navigation Hierarchy/Elements") public reactor.core.publisher.Mono<Void> delete(String dimension, String hierarchy, String element)
      DELETE …/Elements('e'), with the element's edges and data.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      Returns:
      completes when the element is deleted
    • parents

      @Tm1Endpoint("Navigation Element/Parents") public reactor.core.publisher.Flux<Element> parents(String dimension, String hierarchy, String element, ODataQuery query)
      GET …/Elements('e')/Parents, streamed.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      query - what to select, expand, filter and order
      Returns:
      the consolidations the element is in
    • components

      @Tm1Endpoint("Navigation Element/Components") public reactor.core.publisher.Flux<Element> components(String dimension, String hierarchy, String element, ODataQuery query)
      GET …/Elements('e')/Components, streamed.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      query - what to select, expand, filter and order
      Returns:
      the element's children, in order
    • edges

      @Tm1Endpoint("Navigation Element/Edges") public reactor.core.publisher.Flux<Edge> edges(String dimension, String hierarchy, String element, ODataQuery query)
      GET …/Elements('e')/Edges, streamed.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      query - what to select, expand, filter and order
      Returns:
      the edges to the element's children
    • hierarchy

      @Tm1Endpoint("Navigation Element/Hierarchy") public reactor.core.publisher.Mono<Hierarchy> hierarchy(String dimension, String hierarchy, String element, ODataQuery query)
      GET …/Elements('e')/Hierarchy.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      query - what to select and expand
      Returns:
      the element's hierarchy
    • setComponent

      @Tm1Endpoint("Action Element/SetComponent") public reactor.core.publisher.Mono<Void> setComponent(String dimension, String hierarchy, String parent, String child)
      tm1.SetComponent: makes child a child of parent, with weight 1, placed last among its children. ($metadata doesn't say; TM1 11.8 puts it last.)
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      parent - the consolidation's name
      child - the child's name
      Returns:
      completes when the edge is set
    • setComponent

      @Tm1Endpoint("Action Element/SetComponent") public reactor.core.publisher.Mono<Void> setComponent(String dimension, String hierarchy, String parent, String child, double weight)
      tm1.SetComponent: makes child a child of parent with a weight, placed last among its children.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      parent - the consolidation's name
      child - the child's name
      weight - the child's weight in the consolidation
      Returns:
      completes when the edge is set
    • setComponent

      @Tm1Endpoint("Action Element/SetComponent") public reactor.core.publisher.Mono<Void> setComponent(String dimension, String hierarchy, String parent, String child, String before, double weight)
      tm1.SetComponent: makes child a child of parent with a weight, placed just before another child.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      parent - the consolidation's name
      child - the child's name
      before - the name of the child to place it before
      weight - the child's weight in the consolidation
      Returns:
      completes when the edge is set
    • lock

      @Tm1Endpoint("Action Element/Lock") public reactor.core.publisher.Mono<Void> lock(String dimension, String hierarchy, String element)
      tm1.Lock: stops everyone else changing the element until it's unlocked. Needs schema 11.8.23.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      Returns:
      completes when the element is locked
    • unlock

      @Tm1Endpoint("Action Element/Unlock") public reactor.core.publisher.Mono<Void> unlock(String dimension, String hierarchy, String element)
      tm1.Unlock. Needs schema 11.8.23.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      Returns:
      completes when the element is unlocked
    • reserve

      @Tm1Endpoint("Action Element/Reserve") public reactor.core.publisher.Mono<Void> reserve(String dimension, String hierarchy, String element)
      tm1.Reserve: stops everyone else changing the element's data until it's released. Needs schema 11.8.34.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      Returns:
      completes when the element is reserved
    • release

      @Tm1Endpoint("Action Element/Release") public reactor.core.publisher.Mono<Void> release(String dimension, String hierarchy, String element)
      tm1.Release. Needs schema 11.8.34.
      Parameters:
      dimension - the dimension's name
      hierarchy - the hierarchy's name
      element - the element's name
      Returns:
      completes when the element is released