Class CubeService

java.lang.Object
io.skipcheck.tm1.client.service.cube.CubeService

public final class CubeService extends Object
Cubes: /Cubes, a cube's dimensions, and the operations bound to a cube. Views have a service of their own; cell data is read and written through cellsets.

List cubes with a query: here, the model cubes whose names start with "Sales".

// The names of the model cubes starting with "Sales", in name order
return tm1.cubes()
	.modelCubes(ODataQuery.none()
		.select(Cube.NAME)
		.filter(Filter.startsWith(Cube.NAME, "Sales"))
		.orderBy(Cube.NAME))
	.map(Cube::name);

Create a cube over existing dimensions, bound in order:

// A cube over two existing dimensions, in this order
ODataPath dimensions = ODataPath.of("Dimensions");
return tm1.cubes()
	.create(CubePatch.builder()
		.name("Sales")
		.bindDimensions(dimensions.key("Region"), dimensions.key("Month"))
		.build());

Change a cube's rules, checking them first:

// TM1 saves rules even when they don't compile, so check them first
String rules = "SKIPCHECK;\n['Margin'] = N: ['Revenue'] - ['Cost'];";
return tm1.cubes()
	.checkRules("Sales", rules)
	.collectList()
	.flatMap(errors -> errors.isEmpty() ? tm1.cubes().update("Sales", CubePatch.builder().rules(rules).build())
			: Mono.error(new IllegalArgumentException("The rules don't compile: " + errors)));
  • Constructor Details

    • CubeService

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

    • list

      @Tm1Endpoint("EntitySet Cubes") public reactor.core.publisher.Flux<Cube> list(ODataQuery query)
      GET Cubes: every cube, control cubes included, streamed.
      Parameters:
      query - what to select, expand, filter and order
      Returns:
      the cubes
    • modelCubes

      @Tm1Endpoint("FunctionImport ModelCubes") public reactor.core.publisher.Flux<Cube> modelCubes(ODataQuery query)
      ModelCubes(): the cubes that aren't control cubes (whose names start with }), streamed.
      Parameters:
      query - what to select, expand, filter and order
      Returns:
      the model cubes
    • controlCubes

      @Tm1Endpoint("FunctionImport ControlCubes") public reactor.core.publisher.Flux<Cube> controlCubes(ODataQuery query)
      ControlCubes(): the control cubes, such as }ClientGroups, streamed.
      Parameters:
      query - what to select, expand, filter and order
      Returns:
      the control cubes
    • get

      @Tm1Endpoint("EntitySet Cubes") public reactor.core.publisher.Mono<Cube> get(String name, ODataQuery query)
      GET Cubes('name').
      Parameters:
      name - the cube's name
      query - what to select and expand
      Returns:
      the cube, or a Tm1NotFoundException if there's none
    • create

      @Tm1Endpoint("EntitySet Cubes") public reactor.core.publisher.Mono<Cube> create(CubePatch cube)
      POST Cubes: creates a cube over existing dimensions, bound in order with CubePatch.Builder#bindDimensions, and optionally its rules.
      Parameters:
      cube - the new cube; it needs a name and at least two dimensions
      Returns:
      the cube as created
    • update

      @Tm1Endpoint("EntitySet Cubes") public reactor.core.publisher.Mono<Void> update(String name, CubePatch patch)
      PATCH Cubes('name'): changes the properties the patch sets, typically Rules or DrillthroughRules; null clears them.

      TM1 (11.8) saves rules even when they don't compile: check them first with checkRules(String, String).

      Parameters:
      name - the cube's name
      patch - the changes
      Returns:
      completes when the cube is changed
    • update

      @Tm1Endpoint("EntitySet Cubes") public reactor.core.publisher.Mono<Void> update(String name, CubePatch patch, String etag)
      PATCH Cubes('name') with If-Match: changes the properties the patch sets, unless the cube changed since it was read. TM1 (11.8) saves rules even when they don't compile.
      Parameters:
      name - the cube's name
      patch - the changes
      etag - the ETag the cube was read with (Cube.etag())
      Returns:
      completes when the cube is changed, or a Tm1PreconditionFailedException if it had changed
    • delete

      @Tm1Endpoint("EntitySet Cubes") public reactor.core.publisher.Mono<Void> delete(String name)
      DELETE Cubes('name'), with its data and views; its dimensions stay.
      Parameters:
      name - the cube's name
      Returns:
      completes when the cube is deleted
    • dimensions

      @Tm1Endpoint("Navigation Cube/Dimensions") public reactor.core.publisher.Flux<Dimension> dimensions(String name, ODataQuery query)
      GET Cubes('name')/Dimensions, streamed, in the cube's order.

      TM1 (11.8) lists its virtual Sandboxes dimension first, before the dimensions the cube was made of; skip it to get those.

      Parameters:
      name - the cube's name
      query - what to select, expand, filter and order
      Returns:
      the cube's dimensions, Sandboxes first
    • dimensionsStorageOrder

      @Tm1Endpoint("Function Cube/DimensionsStorageOrder") public reactor.core.publisher.Flux<Dimension> dimensionsStorageOrder(String name, ODataQuery query)
      tm1.DimensionsStorageOrder(): the cube's dimensions in the order TM1 stores them, which can differ from the order they're presented in. Needs schema 11.4.0.
      Parameters:
      name - the cube's name
      query - what to select of each dimension
      Returns:
      the dimensions in storage order
    • reorderDimensions

      @Tm1Endpoint("Action Cube/ReorderDimensions") public reactor.core.publisher.Mono<Double> reorderDimensions(String name, List<String> dimensions)
      tm1.ReorderDimensions: changes the order TM1 stores the cube's dimensions in, which changes its memory use but not how it's presented. Needs schema 11.4.0.
      Parameters:
      name - the cube's name
      dimensions - the cube's dimensions, in the new storage order
      Returns:
      the change in the cube's memory use, as TM1 reports it (a percentage)
    • load

      @Tm1Endpoint("Action Cube/Load") public reactor.core.publisher.Mono<Void> load(String name)
      tm1.Load: loads the cube into memory, if it isn't. Needs schema 11.6.0.
      Parameters:
      name - the cube's name
      Returns:
      completes when the cube is loaded
    • unload

      @Tm1Endpoint("Action Cube/Unload") public reactor.core.publisher.Mono<Void> unload(String name)
      tm1.Unload: frees the cube's memory; TM1 loads it again when it's next used. Needs schema 11.6.0.
      Parameters:
      name - the cube's name
      Returns:
      completes when the cube is unloaded
    • lock

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

      @Tm1Endpoint("Action Cube/Unlock") public reactor.core.publisher.Mono<Void> unlock(String name)
      tm1.Unlock.
      Parameters:
      name - the cube's name
      Returns:
      completes when the cube is unlocked
    • reserve

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

      @Tm1Endpoint("Action Cube/Release") public reactor.core.publisher.Mono<Void> release(String name)
      tm1.Release. Needs schema 11.8.34.
      Parameters:
      name - the cube's name
      Returns:
      completes when the cube is released
    • checkRules

      @Tm1Endpoint("Action Cube/CheckRules") public reactor.core.publisher.Flux<RuleSyntaxError> checkRules(String name)
      tm1.CheckRules: compiles the cube's saved rules and lists their errors. Needs schema 11.1.0.
      Parameters:
      name - the cube's name
      Returns:
      the syntax errors, with line numbers; none if the rules compile
    • checkRules

      @Tm1Endpoint("Action Cube/CheckRules") public reactor.core.publisher.Flux<RuleSyntaxError> checkRules(String name, String rules)
      tm1.CheckRules with Rules: compiles rules for the cube without saving them, so they can be checked before update(String, CubePatch) saves them (which TM1 does even when they don't compile). Needs schema 11.1.0.
      Parameters:
      name - the cube's name
      rules - the rules to check
      Returns:
      the syntax errors, with line numbers; none if the rules compile
    • traceCellCalculation

      @Tm1Endpoint("Action Cube/TraceCellCalculation") @Tm1Endpoint("Navigation CalculationComponent/Cube") @Tm1Endpoint("Navigation CalculationComponent/Tuple") public reactor.core.publisher.Mono<CalculationComponent> traceCellCalculation(String name, Map<String,String> tuple, ODataQuery query)
      tm1.TraceCellCalculation: how a cell's value is calculated, as a tree of rule and consolidation components. Needs schema 11.1.0.
      Parameters:
      name - the cube's name
      tuple - the cell: dimension name to element name, for every dimension of the cube in its order (a LinkedHashMap); each element is in its dimension's same-named hierarchy
      query - what to expand of the result, such as Components, Tuple or Cube
      Returns:
      the calculation's root component
    • traceFeeders

      @Tm1Endpoint("Action Cube/TraceFeeders") @Tm1Endpoint("Navigation FedCellDescriptor/Cube") @Tm1Endpoint("Navigation FedCellDescriptor/Tuple") public reactor.core.publisher.Mono<FeederTrace> traceFeeders(String name, Map<String,String> tuple, ODataQuery query)
      tm1.TraceFeeders: which cells a cell feeds, and the feeder statements that do it. Needs schema 11.1.0.
      Parameters:
      name - the cube's name
      tuple - the cell, as for traceCellCalculation(String, Map, ODataQuery)
      query - what to expand of the result, such as FedCells/Tuple: FedCells is a complex property, so TM1 wants a path, not nested options (FedCells($expand=Tuple) gets 400)
      Returns:
      the trace
    • checkFeeders

      @Tm1Endpoint("Action Cube/CheckFeeders") @Tm1Endpoint("Navigation FedCellDescriptor/Cube") @Tm1Endpoint("Navigation FedCellDescriptor/Tuple") public reactor.core.publisher.Flux<FedCellDescriptor> checkFeeders(String name, Map<String,String> tuple, CheckFeedersSelection selection, ODataQuery query)
      tm1.CheckFeeders: the cells under a consolidated cell that are fed, not fed, or both, to find missing feeders. Needs schema 11.1.0.
      Parameters:
      name - the cube's name
      tuple - the cell, as for traceCellCalculation(String, Map, ODataQuery)
      selection - which cells to list
      query - what to expand of each cell, such as Tuple or Cube
      Returns:
      the cells, streamed