CellService
import io.skipcheck.tm1.client.service.data.CellService;Used in the walkthroughs Read and write cells, Run a process and read its result.
Cell writes to a cube, by coordinates. Cells are given as Tuples.of 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 takes one; updateCells 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);
Members
CellService constructor | A service sending its requests through session. |
update | Writes one value to a cell. |
updateCells | Writes many cells, each its own value, in one request. |
updateCells | tm1.UpdateCells with an order. |
CellService
constructorCellService(Tm1Session session) A service sending its requests through session.
Parameters
session- the session
update
Mono<Void> update(String cube, Map<String,String> tuple, 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 value- the value, or
nullto clear the cell
Returns
- completes when it's written
updateCells
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
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
Also in the Javadoc.