Class ProcessService
java.lang.Object
io.skipcheck.tm1.client.service.process.ProcessService
Processes (TurboIntegrator):
/Processes, compiling and running them, and their
error logs.
Parameters go as a map of name to value, in order; a numeric parameter needs a number, not text. Running a process returns when it ends, however long that takes: give the request a timeout that fits, and know that cancelling the call doesn't stop the process on the server.
Create a process, compiling it first, since TM1 saves code that doesn't compile:
// TM1 saves code that doesn't compile, so compile the definition first
ProcessPatch process = ProcessPatch.builder()
.name("Load Sales")
.parameters(List.of(
ProcessParameterPatch.builder()
.name("pVersion")
.value("Actual")
.type(ProcessVariableType.STRING)
.build(),
ProcessParameterPatch.builder()
.name("pYear")
.value(2026)
.type(ProcessVariableType.NUMERIC)
.build()))
.prologProcedure("LogOutput('INFO', 'Loading ' | pVersion | ' for ' | NumberToString(pYear));\n")
.build();
return tm1.processes()
.compile(process)
.collectList()
.flatMap(errors -> errors.isEmpty() ? tm1.processes().create(process)
: Mono.error(new IllegalArgumentException("The process doesn't compile: " + errors)));
Run it with parameters, and fail if it wrote an error log:
// Parameters by name, in order; a numeric one takes a number, not text
Map<String, Object> parameters = new LinkedHashMap<>();
parameters.put("pVersion", "Forecast");
parameters.put("pYear", 2026);
return tm1.processes()
.executeWithReturn("Load Sales", parameters, ODataQuery.none().expand(ProcessExecuteResult.ERROR_LOG_FILE))
.flatMap(result -> {
// A run that ended with errors names the log it wrote
ErrorLogFile log = result.errorLogFile();
return log == null ? Mono.just(result) : Mono
.error(new IllegalStateException(result.processExecuteStatusCode() + ": see " + log.filename()));
});
Run code without saving it as a process:
// A one-off run of code that isn't saved as a process
ProcessPatch cleanup = ProcessPatch.builder()
.name("Clear Sales Staging")
.prologProcedure("CubeClearData('Sales Staging');\n")
.build();
return tm1.processes().executeWithReturn(cleanup, Map.of(), ODataQuery.none());
-
Constructor Summary
ConstructorsConstructorDescriptionProcessService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Flux<ProcessSyntaxError> compile(ProcessPatch definition) CompileProcess: compiles a process definition that needn't be saved, such as one about to be created.reactor.core.publisher.Flux<ProcessSyntaxError> tm1.Compile: compiles a saved process.reactor.core.publisher.Mono<Process> create(ProcessPatch process) POST Processes: creates a process.reactor.core.publisher.Mono<Void> DELETE Processes('name').reactor.core.publisher.Mono<String> errorLogContent(String name, ProcessErrorLog log) Deprecated.reactor.core.publisher.Flux<ProcessErrorLog> errorLogs(String name, ODataQuery query) Deprecated.Deprecated in TM1 schema 11.3.0, withProcessErrorLog: a run's log is theErrorLogFilethatexecuteWithReturn(String, Map, ODataQuery)returns.reactor.core.publisher.Mono<Void> execute(ProcessPatch definition, Map<String, ?> parameters) Deprecated.Deprecated in TM1 schema 11.3.0: useexecuteWithReturn(ProcessPatch, Map, ODataQuery).reactor.core.publisher.Mono<Void> Deprecated.Deprecated in TM1 schema 11.3.0: useexecuteWithReturn(String, Map, ODataQuery).reactor.core.publisher.Mono<ProcessExecuteResult> executeWithReturn(ProcessPatch definition, Map<String, ?> parameters, ODataQuery query) ExecuteProcessWithReturn: runs a process definition that needn't be saved.reactor.core.publisher.Mono<ProcessExecuteResult> executeWithReturn(String name, Map<String, ?> parameters, ODataQuery query) tm1.ExecuteWithReturn: runs a process and says how it ended.reactor.core.publisher.Mono<Process> get(String name, ODataQuery query) GET Processes('name').reactor.core.publisher.Flux<Process> list(ODataQuery query) GET Processes, streamed.reactor.core.publisher.Mono<Void> update(String name, ProcessPatch patch) PATCH Processes('name'): changes the properties the patch sets, such as a procedure.reactor.core.publisher.Mono<Void> update(String name, ProcessPatch patch, String etag) PATCH Processes('name')withIf-Match.
-
Constructor Details
-
ProcessService
A service sending its requests throughsession.- Parameters:
session- the session
-
-
Method Details
-
list
@Tm1Endpoint("EntitySet Processes") public reactor.core.publisher.Flux<Process> list(ODataQuery query) GET Processes, streamed.- Parameters:
query- what to select, expand, filter and order- Returns:
- the processes
-
get
@Tm1Endpoint("EntitySet Processes") public reactor.core.publisher.Mono<Process> get(String name, ODataQuery query) GET Processes('name'). TM1 (11.8) leaves most ofDataSource, andUIDataandVariablesUIData, out of a$select=*: select them by name, or select nothing, to get them.- Parameters:
name- the process's namequery- what to select and expand- Returns:
- the process, or a
Tm1NotFoundExceptionif there's none
-
create
@Tm1Endpoint("EntitySet Processes") public reactor.core.publisher.Mono<Process> create(ProcessPatch process) POST Processes: creates a process. TM1 (11.8) saves code that doesn't compile: check it withcompile(ProcessPatch)first.- Parameters:
process- the new process; it needs a name- Returns:
- the process as created
-
update
@Tm1Endpoint("EntitySet Processes") public reactor.core.publisher.Mono<Void> update(String name, ProcessPatch patch) PATCH Processes('name'): changes the properties the patch sets, such as a procedure. TM1 (11.8) saves code that doesn't compile.- Parameters:
name- the process's namepatch- the changes- Returns:
- completes when the process is changed
-
update
@Tm1Endpoint("EntitySet Processes") public reactor.core.publisher.Mono<Void> update(String name, ProcessPatch patch, String etag) PATCH Processes('name')withIf-Match.- Parameters:
name- the process's namepatch- the changesetag- the ETag the process was read with (Process.etag())- Returns:
- completes when the process is changed, or a
Tm1PreconditionFailedExceptionif it had changed
-
delete
DELETE Processes('name').- Parameters:
name- the process's name- Returns:
- completes when the process is deleted
-
compile
@Tm1Endpoint("Action Process/Compile") public reactor.core.publisher.Flux<ProcessSyntaxError> compile(String name) tm1.Compile: compiles a saved process. Needs schema 11.0.0.- Parameters:
name- the process's name- Returns:
- the syntax errors, by procedure and line; none if it compiles
-
compile
@Tm1Endpoint("ActionImport CompileProcess") public reactor.core.publisher.Flux<ProcessSyntaxError> compile(ProcessPatch definition) CompileProcess: compiles a process definition that needn't be saved, such as one about to be created. Needs schema 11.0.0.- Parameters:
definition- the process, with its procedures and parameters- Returns:
- the syntax errors, by procedure and line; none if it compiles
-
executeWithReturn
@Tm1Endpoint("Action Process/ExecuteWithReturn") @Tm1Endpoint("Navigation ProcessExecuteResult/ErrorLogFile") public reactor.core.publisher.Mono<ProcessExecuteResult> executeWithReturn(String name, Map<String, ?> parameters, ODataQuery query) tm1.ExecuteWithReturn: runs a process and says how it ended. Needs schema 11.3.0. AProcessError, or a runtime error, ends itAborted, with anErrorLogFilenamedtm1processerror_<time>_<process>.log. A run cancelled through its thread (ThreadService.cancel) fails instead, with aTm1ServerException(TM1UserException: Cancel, code 174).- Parameters:
name- the process's nameparameters- its parameters, by name, in order; may be emptyquery- what to expand of the result, such asErrorLogFilewhen it ended with errors- Returns:
- how it ended:
ProcessExecuteStatusCode, and the error log's file if it wrote one
-
executeWithReturn
@Tm1Endpoint("ActionImport ExecuteProcessWithReturn") @Tm1Endpoint("Navigation ProcessExecuteResult/ErrorLogFile") public reactor.core.publisher.Mono<ProcessExecuteResult> executeWithReturn(ProcessPatch definition, Map<String, ?> parameters, ODataQuery query) ExecuteProcessWithReturn: runs a process definition that needn't be saved. Needs schema 11.3.0.- Parameters:
definition- the process, with its procedures and parametersparameters- the values to run it with, by name, in order; may be emptyquery- what to expand of the result, such asErrorLogFile- Returns:
- how it ended
-
execute
@Deprecated(since="11.3.0") @Tm1Endpoint("Action Process/Execute") public reactor.core.publisher.Mono<Void> execute(String name, Map<String, ?> parameters) Deprecated.Deprecated in TM1 schema 11.3.0: useexecuteWithReturn(String, Map, ODataQuery).tm1.Execute: runs a process, without saying how it ended.- Parameters:
name- the process's nameparameters- its parameters, by name, in order; may be empty- Returns:
- completes when it's run
-
execute
@Deprecated(since="11.3.0") @Tm1Endpoint("ActionImport ExecuteProcess") public reactor.core.publisher.Mono<Void> execute(ProcessPatch definition, Map<String, ?> parameters) Deprecated.Deprecated in TM1 schema 11.3.0: useexecuteWithReturn(ProcessPatch, Map, ODataQuery).ExecuteProcess: runs a process definition, without saying how it ended. Needs schema 11.0.0.- Parameters:
definition- the process, with its procedures and parametersparameters- the values to run it with, by name, in order; may be empty- Returns:
- completes when it's run
-
errorLogs
@Deprecated(since="11.3.0") @Tm1Endpoint("Navigation Process/ErrorLogs") public reactor.core.publisher.Flux<ProcessErrorLog> errorLogs(String name, ODataQuery query) Deprecated.Deprecated in TM1 schema 11.3.0, withProcessErrorLog: a run's log is theErrorLogFilethatexecuteWithReturn(String, Map, ODataQuery)returns.GET Processes('name')/ErrorLogs, streamed: the logs its failed runs wrote, keyed by their timestamps.- Parameters:
name- the process's namequery- what to select, filter and order- Returns:
- the error logs
-
errorLogContent
@Deprecated(since="11.3.0") @Tm1Endpoint("Navigation Process/ErrorLogs") public reactor.core.publisher.Mono<String> errorLogContent(String name, ProcessErrorLog log) Deprecated.Deprecated in TM1 schema 11.3.0, withProcessErrorLog: a run's log is theErrorLogFilethatexecuteWithReturn(String, Map, ODataQuery)returns.GET Processes('name')/ErrorLogs('timestamp')/Content: an error log's text. TM1 keys error logs by their timestamp as a quoted string, as it lists it.- Parameters:
name- the process's namelog- the log, aserrorLogs(String, ODataQuery)lists it- Returns:
- the log's text
-
ProcessErrorLog: a run's log is theErrorLogFilethatexecuteWithReturn(String, Map, ODataQuery)returns.