skipcheck

TM1 client · Docs · Reading and writing data

SandboxService

import io.skipcheck.tm1.client.service.data.SandboxService;

Sandboxes: private copies of the data a user writes to before publishing. They belong to the user the session is for.

Reading and writing in a sandbox go through a session view: Tm1Session.withSandbox or Tm1Client.withSandbox, which add TM1's !sandbox option to every request. This service manages the sandboxes themselves.

Create a sandbox, write to it, and publish the changes to base data:

// Write to a new sandbox, leaving base data alone until the changes are published
Map<String, String> cell = new LinkedHashMap<>();
cell.put("Version", "Budget");
cell.put("Region", "North");
cell.put("Month", "Jan");
cell.put("Measure", "Revenue");
Tm1Client whatIf = tm1.withSandbox("What If");
return tm1.sandboxes()
    .create(SandboxPatch.builder().name("What If").build())
    .then(whatIf.cells().update("Sales", cell, 1500))
    .then(tm1.sandboxes().publish("What If"));

Read a cell in base data and in a sandbox:

// The same cell read in base data and in a sandbox: the same query, through a
// client for each
String mdx = "SELECT {[Month].[Month].[Jan]} ON 0, {[Region].[Region].[North]} ON 1 FROM [Sales]"
        + " WHERE ([Version].[Version].[Budget], [Measure].[Measure].[Revenue])";
ODataQuery values = ODataQuery.none().select(CellsetCell.VALUE);
Mono<JsonNode> base = tm1.cellsets()
    .stream(mdx, values, 1, (cellset, cells) -> cells.map(CellsetCell::value))
    .next();
Mono<JsonNode> whatIf = tm1.withSandbox("What If")
    .cellsets()
    .stream(mdx, values, 1, (cellset, cells) -> cells.map(CellsetCell::value))
    .next();
return Mono.zip(base, whatIf, (b, w) -> "base " + b + ", what-if " + w);

Members

SandboxService constructorA service sending its requests through session.
listGET Sandboxes, streamed.
getGET Sandboxes('name').
createCreates an empty sandbox.
updateChanges the properties the patch sets, such as IncludeInSandboxDimension.
deleteDELETE Sandboxes('name'), with its unpublished changes.
loadLoads the sandbox into memory.
unloadFrees the sandbox's memory, keeping its changes.
discardChangesThrows away the sandbox's changes, keeping the sandbox.
publishWrites the sandbox's changes to base data.
publishtm1.Publish with options.
mergeCopies the sandbox's changes into another sandbox.
mergetm1.Merge with options.

SandboxService

constructor
SandboxService(Tm1Session session)

A service sending its requests through session.

Parameters

session
the session

list

Flux<Sandbox> list(ODataQuery query)

GET Sandboxes, streamed: the session user's sandboxes.

Parameters

query
what to select, filter and order

Returns

the sandboxes

TM1 REST EntitySet Sandboxes

get

Mono<Sandbox> get(String name, ODataQuery query)

GET Sandboxes('name').

Parameters

name
the sandbox's name
query
what to select

Returns

the sandbox, or a Tm1NotFoundException if there's none

TM1 REST EntitySet Sandboxes

create

Mono<Sandbox> create(SandboxPatch sandbox)

POST Sandboxes: creates an empty sandbox.

Parameters

sandbox
the new sandbox; it needs a name

Returns

the sandbox as created

TM1 REST EntitySet Sandboxes

update

Mono<Void> update(String name, SandboxPatch patch)

PATCH Sandboxes('name'): changes the properties the patch sets, such as IncludeInSandboxDimension.

Parameters

name
the sandbox's name
patch
the changes

Returns

completes when the sandbox is changed

TM1 REST EntitySet Sandboxes

delete

Mono<Void> delete(String name)

DELETE Sandboxes('name'), with its unpublished changes.

Parameters

name
the sandbox's name

Returns

completes when the sandbox is deleted

TM1 REST EntitySet Sandboxes

load

Mono<Void> load(String name)

tm1.Load: loads the sandbox into memory.

Parameters

name
the sandbox's name

Returns

completes when it's loaded

TM1 REST Action Sandbox/Load

unload

Mono<Void> unload(String name)

tm1.Unload: frees the sandbox's memory, keeping its changes.

Parameters

name
the sandbox's name

Returns

completes when it's unloaded

TM1 REST Action Sandbox/Unload

discardChanges

Mono<Void> discardChanges(String name)

tm1.DiscardChanges: throws away the sandbox's changes, keeping the sandbox.

Parameters

name
the sandbox's name

Returns

completes when they're discarded

TM1 REST Action Sandbox/DiscardChanges

publish

Mono<Void> publish(String name)

tm1.Publish: writes the sandbox's changes to base data.

Parameters

name
the sandbox's name

Returns

completes when they're published

TM1 REST Action Sandbox/Publish

publish

Mono<Void> publish(String name, ConflictResolution conflicts, boolean allowQueueing, boolean cleanAfter)

tm1.Publish with options.

Parameters

name
the sandbox's name
conflicts
what to do with cells changed in base data since the sandbox's changes
allowQueueing
whether to wait for a lock rather than fail
cleanAfter
whether to empty the sandbox once published

Returns

completes when they're published

TM1 REST Action Sandbox/Publish

merge

Mono<Void> merge(String name, String target)

tm1.Merge: copies the sandbox's changes into another sandbox.

Parameters

name
the sandbox's name
target
the name of the sandbox to merge into

Returns

completes when they're merged

TM1 REST Action Sandbox/Merge

merge

Mono<Void> merge(String name, String target, ConflictResolution conflicts, boolean allowQueueing, boolean cleanAfter)

tm1.Merge with options.

Parameters

name
the sandbox's name
target
the name of the sandbox to merge into
conflicts
what to do with cells the target changed too
allowQueueing
whether to wait for a lock rather than fail
cleanAfter
whether to empty this sandbox once merged

Returns

completes when they're merged

TM1 REST Action Sandbox/Merge

Also in the Javadoc.