Class ProcessService

java.lang.Object
io.skipcheck.tm1.client.service.process.ProcessService

public final class ProcessService extends Object
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 Details

    • ProcessService

      public ProcessService(Tm1Session session)
      A service sending its requests through session.
      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 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
    • 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 with compile(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 name
      patch - 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') 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
    • delete

      @Tm1Endpoint("EntitySet Processes") public reactor.core.publisher.Mono<Void> delete(String name)
      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. 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

      @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 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

      @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: use executeWithReturn(String, Map, ODataQuery).
      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
    • 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: use executeWithReturn(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 parameters
      parameters - 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, with ProcessErrorLog: a run's log is the ErrorLogFile that executeWithReturn(String, Map, ODataQuery) returns.
      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
    • 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, with ProcessErrorLog: a run's log is the ErrorLogFile that executeWithReturn(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 name
      log - the log, as errorLogs(String, ODataQuery) lists it
      Returns:
      the log's text