Class SandboxService
java.lang.Object
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);
-
Constructor Summary
ConstructorsConstructorDescriptionSandboxService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Sandbox> create(SandboxPatch sandbox) POST Sandboxes: creates an empty sandbox.reactor.core.publisher.Mono<Void> DELETE Sandboxes('name'), with its unpublished changes.reactor.core.publisher.Mono<Void> discardChanges(String name) tm1.DiscardChanges: throws away the sandbox's changes, keeping the sandbox.reactor.core.publisher.Mono<Sandbox> get(String name, ODataQuery query) GET Sandboxes('name').reactor.core.publisher.Flux<Sandbox> list(ODataQuery query) GET Sandboxes, streamed: the session user's sandboxes.reactor.core.publisher.Mono<Void> tm1.Load: loads the sandbox into memory.reactor.core.publisher.Mono<Void> tm1.Merge: copies the sandbox's changes into another sandbox.reactor.core.publisher.Mono<Void> merge(String name, String target, ConflictResolution conflicts, boolean allowQueueing, boolean cleanAfter) tm1.Mergewith options.reactor.core.publisher.Mono<Void> tm1.Publish: writes the sandbox's changes to base data.reactor.core.publisher.Mono<Void> publish(String name, ConflictResolution conflicts, boolean allowQueueing, boolean cleanAfter) tm1.Publishwith options.reactor.core.publisher.Mono<Void> tm1.Unload: frees the sandbox's memory, keeping its changes.reactor.core.publisher.Mono<Void> update(String name, SandboxPatch patch) PATCH Sandboxes('name'): changes the properties the patch sets, such asIncludeInSandboxDimension.
-
Constructor Details
-
SandboxService
A service sending its requests throughsession.- Parameters:
session- the session
-
-
Method Details
-
list
@Tm1Endpoint("EntitySet Sandboxes") public reactor.core.publisher.Flux<Sandbox> list(ODataQuery query) GET Sandboxes, streamed: the session user's sandboxes.- Parameters:
query- what to select, filter and order- Returns:
- the sandboxes
-
get
@Tm1Endpoint("EntitySet Sandboxes") public reactor.core.publisher.Mono<Sandbox> get(String name, ODataQuery query) GET Sandboxes('name').- Parameters:
name- the sandbox's namequery- what to select- Returns:
- the sandbox, or a
Tm1NotFoundExceptionif there's none
-
create
@Tm1Endpoint("EntitySet Sandboxes") public reactor.core.publisher.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
-
update
@Tm1Endpoint("EntitySet Sandboxes") public reactor.core.publisher.Mono<Void> update(String name, SandboxPatch patch) PATCH Sandboxes('name'): changes the properties the patch sets, such asIncludeInSandboxDimension.- Parameters:
name- the sandbox's namepatch- the changes- Returns:
- completes when the sandbox is changed
-
delete
DELETE Sandboxes('name'), with its unpublished changes.- Parameters:
name- the sandbox's name- Returns:
- completes when the sandbox is deleted
-
load
tm1.Load: loads the sandbox into memory.- Parameters:
name- the sandbox's name- Returns:
- completes when it's loaded
-
unload
tm1.Unload: frees the sandbox's memory, keeping its changes.- Parameters:
name- the sandbox's name- Returns:
- completes when it's unloaded
-
discardChanges
@Tm1Endpoint("Action Sandbox/DiscardChanges") public reactor.core.publisher.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
-
publish
@Tm1Endpoint("Action Sandbox/Publish") public reactor.core.publisher.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
-
publish
@Tm1Endpoint("Action Sandbox/Publish") public reactor.core.publisher.Mono<Void> publish(String name, ConflictResolution conflicts, boolean allowQueueing, boolean cleanAfter) tm1.Publishwith options.- Parameters:
name- the sandbox's nameconflicts- what to do with cells changed in base data since the sandbox's changesallowQueueing- whether to wait for a lock rather than failcleanAfter- whether to empty the sandbox once published- Returns:
- completes when they're published
-
merge
@Tm1Endpoint("Action Sandbox/Merge") public reactor.core.publisher.Mono<Void> merge(String name, String target) tm1.Merge: copies the sandbox's changes into another sandbox.- Parameters:
name- the sandbox's nametarget- the name of the sandbox to merge into- Returns:
- completes when they're merged
-
merge
@Tm1Endpoint("Action Sandbox/Merge") public reactor.core.publisher.Mono<Void> merge(String name, String target, ConflictResolution conflicts, boolean allowQueueing, boolean cleanAfter) tm1.Mergewith options.- Parameters:
name- the sandbox's nametarget- the name of the sandbox to merge intoconflicts- what to do with cells the target changed tooallowQueueing- whether to wait for a lock rather than failcleanAfter- whether to empty this sandbox once merged- Returns:
- completes when they're merged
-