public class ModelInstance extends Object
Modifier and Type | Field and Description |
---|---|
long |
id
The model instance ID.
|
Constructor and Description |
---|
ModelInstance(long id) |
Modifier and Type | Method and Description |
---|---|
void |
escalateTodo(long todoId,
String reasonText) |
void |
escalateTodo(Todo todo,
String reasonText) |
EvaluationResultValue |
evaluateExpressionInEvaluationLevel(String expression,
String evaluationLevel,
boolean mergeEvaluation)
Evaluates expression in the specified evaluation level.
|
EvaluationResultValue |
execute(String expression)
Evaluates expression in base context.
|
EvaluationResultValue |
execute(String expression,
Long contextId)
Evaluates expression in base evaluation level in the specified context.
|
EvaluationResultValue |
execute(String expression,
Todo todo)
Evaluates expression in base evaluation level in the context of the given To-do.
|
List<Todo> |
findAliveTodos()
Finds alive Todos created by this model instance.
|
List<Todo> |
findAliveTodos(String title)
Finds alive Todos created by this model instance.
|
List<Todo> |
findAliveTodosForAdmin()
Finds Todos created by this model instance in the Admin's todo list.
|
List<Todo> |
findAliveTodosForCurrentUser()
Deprecated.
a misleading method name as it returns TODOs for Admin only. Use
findAliveTodosForUser(String) or
findAliveTodosForUser(TestPerson) instead; use findAliveTodosForAdmin() if you really wish to retrieve Admin TODOs. |
List<Todo> |
findAliveTodosForUser(String personId)
Finds Todos created by this model instance in the given person todo list.
|
List<Todo> |
findAliveTodosForUser(TestPerson person)
Finds Todos created by this model instance in the given person todo list.
|
List<RollbackInfo> |
findRollbackInfos()
Returns a list of rollback informations (when model run encounters an exception, the DB transaction is rolled back and a instance is produced).
|
List<Signal> |
findSignals()
Finds signals sent to this model instance.
|
Todo |
findSingleAliveTodo(String title)
Finds an alive Todo with the given title.
|
Todo |
findSingleAliveTodo(String title,
boolean includeContent)
Finds an alive Todo with the given title.
|
Todo |
findSingleAliveTodoForCurrentUser(String title)
Finds an alive Todo with the given title in the todo list of the current user
belonging to this model instance.
|
List<Todo> |
findTodos()
Finds Todos created by this model instance.
|
List<Todo> |
findTodos(TodoStatus status,
String title)
Finds todos with the given status and a title which match the given
title pattern.
|
EvaluationResultValue |
gc()
Performs a GC.
|
GoalState |
getGoalState(String goal)
Returns a state of the given goal.
|
ModelInstanceInfo |
getInfo() |
ModelInstanceLogs |
getLogs()
Gets all log entries for this model instance.
|
long |
getMainContextId() |
String |
getModelName() |
String |
getModelVersion() |
ModelInstanceLogs |
getNewLogs()
Gets the log entries that were added after the method
getLogs() or getNewLogs()
was called the last time. |
ProcessInstance |
getProcessInstance(String name)
Returns the single process instance with given name for this model instance.
|
List<ProcessInstance> |
getProcessInstances(String name)
Finds all process instances for this model instance, with given name.
|
ProcessInstanceState |
getProcessInstanceState(String name)
Returns the state of a process instance with given name.
|
List<Signal> |
getSignalQueue()
Returns the signal queue for this model instance.
|
ModelInstanceState |
getState()
Returns the model instance state
|
Object |
getVariableValue(String name)
Returns the global variable value.
|
void |
notifyModelInstance()
Wakes up the model execution and continues the processing.
|
void |
resumeModelInstance()
Resumes the model execution.
|
void |
sendSignal(String signal)
Sends a signal to this model instance, with given signal value, or payload.
|
void |
stop()
Stops this model instance.
|
void |
submitTodo(String title)
Asserts that there is a single alive todo with a given title
and submits it.
|
void |
submitTodo(Todo todo) |
void |
submitTodos(Iterable<Todo> todos) |
void |
suspendModelInstance()
Suspends the model execution.
|
long |
updateModel(String migrationName,
ByteData migrationConfig)
Updates a model.
|
void |
waitForGoalState(String goalName,
GoalState state)
Awaits for given goal to enter given state, but at most for 60 seconds.
|
void |
waitForGoalState(String goalName,
GoalState state,
long timeoutMillis)
Awaits for given goal to enter given state, but at most for given time duration.
|
boolean |
waitForLogPresent(String logMessage) |
boolean |
waitForLogPresent(String logMessage,
long timeoutMillis) |
void |
waitForSignal(String signalString,
long timeoutMillis) |
Todo |
waitForSingleAliveTodo(String title) |
Todo |
waitForSingleAliveTodo(String title,
long timeoutMillis) |
void |
waitForState(ModelInstanceState state)
Waits at most 60 seconds for the model instance to reach given state.
|
void |
waitForState(ModelInstanceState state,
long timeoutMillis)
Waits for the model instance to reach given state.
|
void |
waitForVariableNotNull(String variableName,
long timeoutMillis)
Awaits for given variable to become assigned with a not-null value.
|
public String getModelName()
public String getModelVersion()
public EvaluationResultValue execute(String expression) throws ErrorException, ValidationException
expression
- ValidationException
ErrorException
public EvaluationResultValue execute(String expression, Long contextId) throws ErrorException, ValidationException
expression
- contextId
- ErrorException
ValidationException
public EvaluationResultValue execute(String expression, Todo todo) throws ErrorException, ValidationException
expression
- todo
- ErrorException
ValidationException
public EvaluationResultValue evaluateExpressionInEvaluationLevel(String expression, String evaluationLevel, boolean mergeEvaluation) throws ErrorException, ValidationException
expression
- evaluationLevel
- mergeEvaluation
- ErrorException
ValidationException
public void stop()
public ModelInstanceLogs getLogs()
public ModelInstanceLogs getNewLogs()
getLogs()
or getNewLogs()
was called the last time.public void submitTodo(Todo todo)
todo
- public void escalateTodo(long todoId, String reasonText)
public ModelInstanceState getState()
public ModelInstanceInfo getInfo()
public void sendSignal(String signal)
signal
- the signal value, may be null.public List<Todo> findTodos(TodoStatus status, String title)
status
- the status of the searched todostitle
- the titlepublic List<Todo> findAliveTodos()
public List<Todo> findAliveTodos(String title)
title
- a titlepublic List<Todo> findTodos()
@Deprecated public List<Todo> findAliveTodosForCurrentUser()
findAliveTodosForUser(String)
or
findAliveTodosForUser(TestPerson)
instead; use findAliveTodosForAdmin()
if you really wish to retrieve Admin TODOs.public List<Todo> findAliveTodosForAdmin()
public List<Todo> findAliveTodosForUser(String personId) throws PersonNotFoundException
personId
- PersonNotFoundException
public List<Todo> findAliveTodosForUser(TestPerson person) throws PersonNotFoundException
person
- a personPersonNotFoundException
public Todo findSingleAliveTodo(String title)
title
- the title of the Todonull
if no such Todo exists.RuntimeException
- if more than one such a Todo is foundpublic Todo findSingleAliveTodo(String title, boolean includeContent)
title
- the title of the TodoincludeContent
- a flag specifying whether Todo content should be includednull
if no such Todo exists.RuntimeException
- if more than one such a Todo is foundpublic Todo findSingleAliveTodoForCurrentUser(String title)
title
- null
if no such Todo exists.RuntimeException
- if more than one such a Todo is foundpublic List<Signal> findSignals()
public void submitTodo(String title)
title
- public void waitForState(ModelInstanceState state) throws InterruptedException
state
- expected state, not null.InterruptedException
AssertionError
- if the model does not reach given state in given time period.public void waitForState(ModelInstanceState state, long timeoutMillis) throws InterruptedException
state
- expected state, not null.timeoutMillis
- wait at most this amount of milliseconds.InterruptedException
AssertionError
- if the model does not reach given state in given time period.public Todo waitForSingleAliveTodo(String title) throws InterruptedException
InterruptedException
public Todo waitForSingleAliveTodo(String title, long timeoutMillis) throws InterruptedException
InterruptedException
public boolean waitForLogPresent(String logMessage) throws InterruptedException
InterruptedException
public boolean waitForLogPresent(String logMessage, long timeoutMillis) throws InterruptedException
InterruptedException
public GoalState getGoalState(String goal)
goal
- the goal namepublic void waitForVariableNotNull(String variableName, long timeoutMillis) throws InterruptedException
variableName
- the variable name, not null.timeoutMillis
- wait at most this amount of millisecondsInterruptedException
AssertionError
- if the variable is null after given time period ellapses.public void waitForGoalState(String goalName, GoalState state) throws InterruptedException
goalName
- the goal name, not null.state
- expected state, not null.InterruptedException
AssertionError
- if the goal is not in given state.public void waitForGoalState(String goalName, GoalState state, long timeoutMillis) throws InterruptedException
goalName
- the goal name, not null.state
- expected state, not null.timeoutMillis
- wait at most this amount of millisecondsInterruptedException
AssertionError
- if the goal is not in given state.public void waitForSignal(String signalString, long timeoutMillis) throws InterruptedException
InterruptedException
public ProcessInstanceState getProcessInstanceState(String name)
name
- the process instance name, not null.RuntimeException
- if there is no such process instance, or if there are two or more process instances.public ProcessInstance getProcessInstance(String name)
name
- necessary process instance name, not null.RuntimeException
- if there are multiple process instances with given name.public List<ProcessInstance> getProcessInstances(String name)
name
- required name, not null.public long getMainContextId()
public Object getVariableValue(String name)
name
- the global variable name.public void notifyModelInstance()
execute(String)
changes value of some variable, used in some model's condition
and the execution may now continue.public void suspendModelInstance()
public void resumeModelInstance()
public long updateModel(String migrationName, ByteData migrationConfig)
migrationName
- migration namemigrationConfig
- the .muc file contents. Use new ByteData(Files.readAllBytes(path)) to read the file.public List<RollbackInfo> findRollbackInfos()
public EvaluationResultValue gc()
Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.