Class CellService

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

public final class CellService extends Object
Cell writes to a cube, by coordinates. Cells are given as Tuples.of(Map) maps of dimension to element; reading is through cellsets (CellsetService), and writing into one by ordinal is there too.

Values are numbers for numeric cells and text for string cells; null clears a cell. TM1 (11.8) refuses a write to a consolidated cell (400, CubeCellWriteStatusElementIsConsolidated): it doesn't spread; write the leaves.

tm1.Update takes several cells, but TM1 (11.8) writes only the first, so update(String, Map, Object) takes one; updateCells(String, List) writes many in one request.

Write one cell, given an element for every dimension of the cube, in order:

// The cell: an element for every dimension of the cube, in the cube's order
Map<String, String> cell = new LinkedHashMap<>();
cell.put("Version", "Budget");
cell.put("Region", "North");
cell.put("Month", "Jan");
cell.put("Measure", "Revenue");
return tm1.cells().update("Sales", cell, 1200);

Write many cells in one request:

// A budget for North, one value per month, written in one request
Map<String, Integer> budget = new LinkedHashMap<>();
budget.put("Jan", 1200);
budget.put("Feb", 1350);
budget.put("Mar", 1100);
List<CubeUpdatePatch> updates = new ArrayList<>();
budget.forEach((month, value) -> {
	Map<String, String> cell = new LinkedHashMap<>();
	cell.put("Version", "Budget");
	cell.put("Region", "North");
	cell.put("Month", month);
	cell.put("Measure", "Revenue");
	updates.add(CubeUpdatePatch.builder().bindTuple(Tuples.of(cell)).value(value).build());
});
return tm1.cells().updateCells("Sales", updates);
  • Constructor Details

    • CellService

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

    • update

      @Tm1Endpoint("Action Cube/Update") @Tm1Endpoint("Navigation CellDescriptor/Tuple") public reactor.core.publisher.Mono<Void> update(String cube, Map<String,String> tuple, @Nullable Object value)
      tm1.Update: writes one value to a cell.
      Parameters:
      cube - the cube's name
      tuple - the cell: dimension to element, as for Tuples.of(Map)
      value - the value, or null to clear the cell
      Returns:
      completes when it's written
    • updateCells

      @Tm1Endpoint("Action Cube/UpdateCells") @Tm1Endpoint("Navigation CubeUpdate/Tuple") @Tm1Endpoint("Navigation CubeUpdate/ReferenceCube") @Tm1Endpoint("Navigation CubeUpdate/ReferenceCell") public reactor.core.publisher.Mono<Void> updateCells(String cube, List<CubeUpdatePatch> updates)
      tm1.UpdateCells: writes many cells, each its own value, in one request. Needs schema 11.0.0. TM1 (11.8) requires a Tuple and a Value in every update (400 otherwise). The patch can also bind a ReferenceCube and ReferenceCell; on a leaf they didn't change what's written, and they don't copy that cell's value.
      Parameters:
      cube - the cube's name
      updates - the writes: CubeUpdatePatch.builder().bindTuple(Tuples.of(cell)).value(v), or with a reference cube and cell to copy from
      Returns:
      completes when they're written
    • updateCells

      @Tm1Endpoint("Action Cube/UpdateCells") @Tm1Endpoint("Navigation CubeUpdate/Tuple") @Tm1Endpoint("Navigation CubeUpdate/ReferenceCube") @Tm1Endpoint("Navigation CubeUpdate/ReferenceCell") public reactor.core.publisher.Mono<Void> updateCells(String cube, List<CubeUpdatePatch> updates, UpdateOrder order)
      tm1.UpdateCells with an order: ByLevel writes leaves before the consolidations above them, so a spread to a consolidation isn't overwritten. Needs schema 11.0.0.
      Parameters:
      cube - the cube's name
      updates - the writes
      order - the order to apply them in
      Returns:
      completes when they're written