skipcheck

TM1 client · Docs · Processes and chores

ProcessService

import io.skipcheck.tm1.client.service.process.ProcessService;

Used in the walkthrough Run a process and read its result.

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());

Members

ProcessService constructorA service sending its requests through session.
listGET Processes, streamed.
getGET Processes('name').
createCreates a process.
updateChanges the properties the patch sets, such as a procedure.
updatePATCH Processes('name') with If-Match.
deleteDELETE Processes('name').
compileCompiles a saved process.
compileCompiles a process definition that needn't be saved, such as one about to be created.
executeWithReturnRuns a process and says how it ended.
executeWithReturnRuns a process definition that needn't be saved.
executeRuns a process, without saying how it ended.
executeRuns a process definition, without saying how it ended.
errorLogsGET Processes('name')/ErrorLogs, streamed.
errorLogContentAn error log's text.

ProcessService

constructor
ProcessService(Tm1Session session)

A service sending its requests through session.

Parameters

session
the session

list

Flux<Process> list(ODataQuery query)

GET Processes, streamed.

Parameters

query
what to select, expand, filter and order

Returns

the processes

TM1 REST EntitySet Processes

get

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

GET Processes('name'). TM1 (11.8) leaves most of DataSource, and UIData and VariablesUIData, out of a $select=*: select them by name, or select nothing, to get them.

Parameters

name
the process's name
query
what to select and expand

Returns

the process, or a Tm1NotFoundException if there's none

TM1 REST EntitySet Processes

create

Mono<Process> create(ProcessPatch process)

POST Processes: creates a process. TM1 (11.8) saves code that doesn't compile: check it with compile first.

Parameters

process
the new process; it needs a name

Returns

the process as created

TM1 REST EntitySet Processes

update

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 name
patch
the changes

Returns

completes when the process is changed

TM1 REST EntitySet Processes

update

Mono<Void> update(String name, ProcessPatch patch, String etag)

PATCH Processes('name') with If-Match.

Parameters

name
the process's name
patch
the changes
etag
the ETag the process was read with (Process.etag)

Returns

completes when the process is changed, or a Tm1PreconditionFailedException if it had changed

TM1 REST EntitySet Processes

delete

Mono<Void> delete(String name)

DELETE Processes('name').

Parameters

name
the process's name

Returns

completes when the process is deleted

TM1 REST EntitySet Processes

compile

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

TM1 REST Action Process/Compile

compile

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

TM1 REST ActionImport CompileProcess

executeWithReturn

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. A ProcessError, or a runtime error, ends it Aborted, with an ErrorLogFile named tm1processerror_<time>_<process>.log. A run cancelled through its thread (ThreadService.cancel) fails instead, with a Tm1ServerException (TM1UserException: Cancel, code 174).

Parameters

name
the process's name
parameters
its parameters, by name, in order; may be empty
query
what to expand of the result, such as ErrorLogFile when it ended with errors

Returns

how it ended: ProcessExecuteStatusCode, and the error log's file if it wrote one

executeWithReturn

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 parameters
parameters
the values to run it with, by name, in order; may be empty
query
what to expand of the result, such as ErrorLogFile

Returns

how it ended

execute

Mono<Void> execute(String name, Map<String,?> parameters)

tm1.Execute: runs a process, without saying how it ended.

Parameters

name
the process's name
parameters
its parameters, by name, in order; may be empty

Returns

completes when it's run

TM1 REST Action Process/Execute

execute

Mono<Void> execute(ProcessPatch definition, Map<String,?> parameters)

ExecuteProcess: runs a process definition, without saying how it ended. Needs schema 11.0.0.

Parameters

definition
the process, with its procedures and parameters
parameters
the values to run it with, by name, in order; may be empty

Returns

completes when it's run

TM1 REST ActionImport ExecuteProcess

errorLogs

Flux<ProcessErrorLog> errorLogs(String name, ODataQuery query)

GET Processes('name')/ErrorLogs, streamed: the logs its failed runs wrote, keyed by their timestamps.

Parameters

name
the process's name
query
what to select, filter and order

Returns

the error logs

TM1 REST Navigation Process/ErrorLogs

errorLogContent

Mono<String> errorLogContent(String name, ProcessErrorLog log)

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 name
log
the log, as errorLogs lists it

Returns

the log's text

TM1 REST Navigation Process/ErrorLogs

Also in the Javadoc.