Class ChangeSetService
java.lang.Object
io.skipcheck.tm1.client.service.data.ChangeSetService
Change sets: groups of cell writes that can be undone together.
A write joins a change set through TM1's !ChangeSet query option, which a
session view from Tm1Session.withChangeSet(String) adds to every request
($metadata doesn't say how; TM1 11.8 does it this way). within(Function) does it
all: begins a change set, gives the work a session that records into it, and ends it
however the work finishes.
Make some writes in a change set, keeping its ID:
// Record some writes in a change set, and keep its ID to undo them later
Map<String, String> cell = new LinkedHashMap<>();
cell.put("Version", "Forecast");
cell.put("Region", "North");
cell.put("Month", "Jan");
cell.put("Measure", "Revenue");
return tm1.changeSets().within(session -> {
String id = session.changeSet().orElseThrow();
return Tm1Client.of(session).cells().update("Sales", cell, 1500).thenReturn(id);
}).single();
Undo them later:
// Revert every write recorded in the change set; writes outside it stay
return tm1.changeSets().undo(changeSet);
-
Constructor Summary
ConstructorsConstructorDescriptionChangeSetService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<String> begin()BeginChangeSet: starts a change set.reactor.core.publisher.Mono<Long> EndChangeSet: stops recording into a change set; it can still be undone.reactor.core.publisher.Mono<Void> UndoChangeSet: reverts every write recorded in a change set.<R> reactor.core.publisher.Flux<R> within(Function<Tm1Session, org.reactivestreams.Publisher<R>> work) Runsworkin a new change set: begins it, gives the work a view of the session that records into it (session.changeSet()has the ID, for a laterundo(String)), and ends it when the work completes, fails or is cancelled.
-
Constructor Details
-
ChangeSetService
A service sending its requests throughsession.- Parameters:
session- the session
-
-
Method Details
-
begin
BeginChangeSet: starts a change set. Needs schema 10.2.2.6.- Returns:
- the change set's ID, for
Tm1Session.withChangeSet(String)
-
end
EndChangeSet: stops recording into a change set; it can still be undone. Needs schema 10.2.2.6.- Parameters:
id- the change set's ID- Returns:
- TM1's return code
-
undo
UndoChangeSet: reverts every write recorded in a change set. Needs schema 10.2.2.6.- Parameters:
id- the change set's ID- Returns:
- completes when the writes are reverted
-
within
@Tm1Endpoint("ActionImport BeginChangeSet") @Tm1Endpoint("ActionImport EndChangeSet") public <R> reactor.core.publisher.Flux<R> within(Function<Tm1Session, org.reactivestreams.Publisher<R>> work) Runsworkin a new change set: begins it, gives the work a view of the session that records into it (session.changeSet()has the ID, for a laterundo(String)), and ends it when the work completes, fails or is cancelled.// Record some writes in a change set, and keep its ID to undo them later Map<String, String> cell = new LinkedHashMap<>(); cell.put("Version", "Forecast"); cell.put("Region", "North"); cell.put("Month", "Jan"); cell.put("Measure", "Revenue"); return tm1.changeSets().within(session -> { String id = session.changeSet().orElseThrow(); return Tm1Client.of(session).cells().update("Sales", cell, 1500).thenReturn(id); }).single();- Type Parameters:
R- what the work gives- Parameters:
work- the writes to record, given the session to make them through- Returns:
- what the work gives, with the change set ended at the end
-