Class DrillthroughService

java.lang.Object
io.skipcheck.tm1.client.service.data.DrillthroughService

public final class DrillthroughService extends Object
Drillthrough: from a cell to the detail behind it, through a drillthrough process (}Drill_…). A cube drillthrough returns a cellset, of a view the process returns; a relational one returns rows from an ODBC source, directly or kept as a Rowset.

A cell's drillthroughs come from the cube's DrillthroughRules, which name the process; scripts(String, long, ODataQuery) lists them for a cell of a cellset. TM1 (11.8) passes such a process the cube's name and the cell's element on each of its dimensions, so the process must declare that many parameters (the cube's name, then one per dimension, in order); otherwise running the cell's drillthrough fails with "process parameter count error" (code 248). Run directly (executeProcess(String, List, ODataQuery)), it takes the parameters given. The returned cellsets and rowsets stay on the server until deleted, like any cellset.

$metadata declares a relational row (DrillthroughRow) with no properties and not open, so its columns would all be lost in a typed row: relational rows come as plain JSON. A rowset's rows (RowsetRow) are open, and keep theirs in dynamicProperties.

Drill from a cell of a query to the detail behind it:

// The detail behind one cell: query it, run its first cube drillthrough, and read
// the cellset that returns. Both cellsets are deleted at the end.
CellsetService cellsets = tm1.cellsets();
DrillthroughService drillthrough = tm1.drillthrough();
String mdx = "SELECT {[Month].[Month].[Jan]} ON 0, {[Region].[Region].[North]} ON 1 FROM [Sales]"
		+ " WHERE ([Version].[Version].[Actual], [Measure].[Measure].[Revenue])";
ODataQuery cells = ODataQuery.none()
	.expand(Cellset.CELLS, c -> c.select(CellsetCell.ORDINAL, CellsetCell.VALUE));
return Flux.usingWhen(cellsets.execute(mdx, ODataQuery.none()),
		source -> drillthrough.scripts(source.id(), 0, ODataQuery.none())
			.filter(CubeDrillthrough.class::isInstance)
			.next()
			.flatMapMany(script -> Flux.usingWhen(drillthrough.execute(source.id(), 0, script.name(), cells),
					detail -> Flux.fromIterable(detail.cells()), detail -> cellsets.delete(detail.id()))),
		source -> cellsets.delete(source.id()));

Run a drillthrough process directly, with its parameters:

// A drillthrough process run directly, with the parameters it declares
CellsetService cellsets = tm1.cellsets();
List<ProcessParameterPatch> parameters = List.of(
		ProcessParameterPatch.builder().name("pRegion").value("North").build(),
		ProcessParameterPatch.builder().name("pMonth").value("Jan").build());
return Flux.usingWhen(
		tm1.drillthrough()
			.executeProcess("}Drill_Sales Detail", parameters,
					ODataQuery.none().expand(Cellset.CELLS, c -> c.select(CellsetCell.VALUE))),
		detail -> Flux.fromIterable(detail.cells()), detail -> cellsets.delete(detail.id()));

Read the rows of a relational drillthrough as a rowset:

// Rows from a relational drillthrough, kept as a rowset and streamed from it.
// Each row's columns are in its dynamic properties.
DrillthroughService drillthrough = tm1.drillthrough();
return Flux.usingWhen(drillthrough.executeRelationalProcessWithRowset("}Drill_Sales Orders", List.of()),
		rowset -> drillthrough.rows(rowset.id(), ODataQuery.none())
			.map(row -> row.dynamicProperties().get("OrderNumber").asString()),
		rowset -> drillthrough.deleteRowset(rowset.id()));
  • Constructor Details

    • DrillthroughService

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

    • scripts

      @Tm1Endpoint("Navigation CellsetCell/DrillthroughScripts") public reactor.core.publisher.Flux<Drillthrough> scripts(String cellset, long ordinal, ODataQuery query)
      GET Cellsets('id')/Cells(n)/DrillthroughScripts: the drillthroughs a cell has, streamed, each a CubeDrillthrough or RelationalDrillthrough.
      Parameters:
      cellset - the cellset's ID
      ordinal - the cell's ordinal
      query - what to select
      Returns:
      the drillthroughs, by name
    • execute

      @Tm1Endpoint("Action CubeDrillthrough/Execute") public reactor.core.publisher.Mono<Cellset> execute(String cellset, long ordinal, String drillthrough, ODataQuery query)
      tm1.Execute on a cell's cube drillthrough: the cellset of the view its process returns, left on the server until deleted. Needs schema 10.2.2.6. The process must take the cube's name and one parameter per dimension (see the class description).
      Parameters:
      cellset - the cellset's ID
      ordinal - the cell's ordinal
      drillthrough - the drillthrough's name, from scripts(String, long, ODataQuery)
      query - what to expand of the cellset
      Returns:
      the cellset
    • executeRelational

      @Tm1Endpoint("Action RelationalDrillthrough/Execute") public reactor.core.publisher.Flux<tools.jackson.databind.JsonNode> executeRelational(String cellset, long ordinal, String drillthrough)
      tm1.Execute on a cell's relational drillthrough: its rows, streamed. Needs schema 10.2.2.6.
      Parameters:
      cellset - the cellset's ID
      ordinal - the cell's ordinal
      drillthrough - the drillthrough's name, from scripts(String, long, ODataQuery)
      Returns:
      the rows, as JSON
    • executeRelationalWithRowset

      @Tm1Endpoint("Action RelationalDrillthrough/ExecuteWithRowset") public reactor.core.publisher.Mono<Rowset> executeRelationalWithRowset(String cellset, long ordinal, String drillthrough)
      tm1.ExecuteWithRowset on a cell's relational drillthrough: its rows, kept as a rowset to read with rows(String, ODataQuery). Needs schema 11.6.0.
      Parameters:
      cellset - the cellset's ID
      ordinal - the cell's ordinal
      drillthrough - the drillthrough's name, from scripts(String, long, ODataQuery)
      Returns:
      the rowset, with its ID
    • executeProcess

      @Tm1Endpoint("ActionImport ExecuteCubeDrillthrough") public reactor.core.publisher.Mono<Cellset> executeProcess(String process, List<ProcessParameterPatch> parameters, ODataQuery query)
      ExecuteCubeDrillthrough: runs a cube drillthrough process directly, with its parameters, and returns the cellset of the view it returns. Needs schema 11.2.0.
      Parameters:
      process - the drillthrough process's name, such as }Drill_Sales
      parameters - the process's parameters, by name and value
      query - what to expand of the cellset
      Returns:
      the cellset, left on the server until deleted
    • executeRelationalProcess

      @Tm1Endpoint("ActionImport ExecuteRelationalDrillthrough") public reactor.core.publisher.Flux<tools.jackson.databind.JsonNode> executeRelationalProcess(String process, List<ProcessParameterPatch> parameters)
      ExecuteRelationalDrillthrough: runs a relational drillthrough process directly. Needs schema 11.2.0.
      Parameters:
      process - the drillthrough process's name
      parameters - the process's parameters
      Returns:
      the rows, as JSON, streamed
    • executeRelationalProcessWithRowset

      @Tm1Endpoint("ActionImport ExecuteRelationalDrillthroughWithRowset") public reactor.core.publisher.Mono<Rowset> executeRelationalProcessWithRowset(String process, List<ProcessParameterPatch> parameters)
      ExecuteRelationalDrillthroughWithRowset: runs a relational drillthrough process directly, keeping its rows as a rowset. Needs schema 11.6.0.
      Parameters:
      process - the drillthrough process's name
      parameters - the process's parameters
      Returns:
      the rowset, with its ID
    • rowset

      @Tm1Endpoint("EntitySet Rowsets") public reactor.core.publisher.Mono<Rowset> rowset(String id, ODataQuery query)
      GET Rowsets('id').
      Parameters:
      id - the rowset's ID
      query - what to expand
      Returns:
      the rowset
    • rows

      @Tm1Endpoint("Navigation Rowset/Rows") public reactor.core.publisher.Flux<RowsetRow> rows(String id, ODataQuery query)
      GET Rowsets('id')/Rows, streamed: each row's columns are in its dynamicProperties.
      Parameters:
      id - the rowset's ID
      query - what to select, filter, and page ($top, $skip)
      Returns:
      the rows
    • deleteRowset

      @Tm1Endpoint("EntitySet Rowsets") public reactor.core.publisher.Mono<Void> deleteRowset(String id)
      DELETE Rowsets('id'): frees the rowset on the server.
      Parameters:
      id - the rowset's ID
      Returns:
      completes when it's deleted