ChangeSetService
import 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 adds to every request
($metadata doesn't say how; TM1 11.8 does it this way). within 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);
Members
ChangeSetService constructor | A service sending its requests through session. |
begin | Starts a change set. |
end | Stops recording into a change set; it can still be undone. |
undo | Reverts every write recorded in a change set. |
within | Runs work in a new change set. |
ChangeSetService
constructorChangeSetService(Tm1Session session) A service sending its requests through session.
Parameters
session- the session
begin
Mono<String> begin() BeginChangeSet: starts a change set. Needs schema 10.2.2.6.
Returns
- the change set's ID, for
Tm1Session.withChangeSet
TM1 REST ActionImport BeginChangeSet
end
Mono<Long> end(String id) 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
TM1 REST ActionImport EndChangeSet
undo
Mono<Void> undo(String id) 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
TM1 REST ActionImport UndoChangeSet
within
<R> Flux<R> within(Function<Tm1Session,Publisher<R>> work) Runs work in 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 later
undo), 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();
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
Also in the Javadoc.