Package de.xima.fc.workflow.taglib.model
Class FlowchartModel
- java.lang.Object
-
- de.xima.fc.workflow.taglib.model.FlowchartModel
-
- All Implemented Interfaces:
Serializable
public final class FlowchartModel extends Object implements Serializable
Model for theFlowchartcomponent. This is what needs to be passed to the<wf:flowchart value="..." />property.Notes regarding
process. Initially, when theFlowchartcomponent is first rendered, the entire model is sent to the client as JSON. Only the client updates the process model. Updates are sent back to the server as JSON patches. This ensures that the client and the server are in sync.Notes regarding
externalState. Initially, when theFlowchartcomponent is first rendered, the entire state is sent to the client as JSON. Only the server updates the external state.. Updates are sent to client during a JSF AJAX update (only when the external state has actually changed.)- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckUpdateIndex(Long updateIndex)Checks whether the update received from the client is valid.voidclearCollapsedNodes()Clears the hidden expansion of all nodes, making all nodes expanded again.voidclearHiddenTasks()Clears the hidden state of all tasks, making all tasks visible again.static FlowchartModelempty()Creates a new flowchart model with the default for all values.booleangetAndClearBackupClearFlag()Clears the flag, and returns its value before it was cleared.booleangetAndClearUpdateSources()Set<NodeKey>getCollapsedNodes()Map<ElementKey,ElementMessageSetModel>getElementMessagesMap()FlowchartSelection<?>getFlowchartSelection()Set<UUID>getHiddenTasks()HistoryInfogetHistoryInfo()Map<ElementKey,com.alibaba.fastjson.JSONObject>getParamsMap()ElementMessageSetModelgetProcessMessages()ProcessModelgetProcessModel()TaskModelgetTaskByUuid(UUID taskUuid)Map<UUID,ElementMessageSetModel>getTaskMessagesMap()IVersionInfogetVersion()booleanisHasExternalStateChanged()booleanisShowLaneSeparators()static FlowchartModelof(ProcessModel processModel, Map<ElementKey,com.alibaba.fastjson.JSONObject> customParamsMap)Creates a new flowchart model with the given data.voidqueueElementMessagesUpdate(ElementKey key, ElementMessageSetModel messages)Adds the given messages for a node or trigger to this model, and replaces all messages previously associated with that node or trigger.voidqueueParamsUpdate(ElementKey key, com.alibaba.fastjson.JSONObject customParams)When the server wants to make changes to the custom parameters of aNodeModelorTriggerModel, this method needs to be used.voidqueuePatches(Collection<? extends JsonPatchUpdate> patches)When the model on the client side has changed, the client sends a list of JSON patch-like objects so that the server can update its model.voidqueueProcessMessagesUpdate(ElementMessageSetModel messages)Adds the given messages for the process to this model, and replaces all messages previously associated with the process.voidqueueSelectionUpdate(FlowchartSelection<?> selection)voidqueueTaskMessagesUpdate(UUID key, ElementMessageSetModel messages)Adds the given messages for a task to this model, and replaces all messages previously associated with that task.voidqueueUpdateSources()Update the drag sources, trigger add sources and node add sources on the client.voidrequestClearBackup()Clear the backup saved on the client.voidsetFlowchartSelection(FlowchartSelection<?> selected)voidsetHideTask(UUID taskUuid, boolean hide)By default all tasks are shown.voidsetNodeCollapsed(NodeKey nodeKey, boolean collapsed)By default all nodes are expanded.voidsetShowLaneSeparators(boolean showLaneSeparators)booleanupdateElementMessages(ElementKey key, ElementMessageSetModel messages)Inserts the given messages for the node or trigger.voidupdateElementMessages(Map<ElementKey,ElementMessageSetModel> messageMap)Inserts the given messages for the node or trigger.voidupdateExternalState(com.alibaba.fastjson.JSONObject externalState)voidupdateHistoryInfo(HistoryInfo historyInfo)Called by the flowchart.voidupdateNodeExpansion(Map<NodeKey,Boolean> updates)booleanupdateParams(ElementKey key, com.alibaba.fastjson.JSONObject customParams)Replaces the custom node or trigger parameters with the given data.voidupdateProcessMessages(ElementMessageSetModel messages)Sets the given messages for the process.voidupdateTaskMessages(Map<UUID,ElementMessageSetModel> messageMap)Inserts the given messages for the tasks.voidupdateTaskMessages(UUID key, ElementMessageSetModel messages)Inserts the given messages for a task.static FlowchartModelwithMessages(ProcessModel processModel, Map<ElementKey,com.alibaba.fastjson.JSONObject> customParamsMap, ElementMessageSetModel processMessages, Map<UUID,ElementMessageSetModel> taskMessagesMap, Map<ElementKey,ElementMessageSetModel> elementMessagesMap)Creates a new flowchart model with the given data.
-
-
-
Method Detail
-
checkUpdateIndex
public boolean checkUpdateIndex(Long updateIndex)
Checks whether the update received from the client is valid.- Parameters:
updateIndex- Incrementing index send by the client. Patches must be received in order, or otherwise they will not work.- Returns:
- Whether the update index was valid.
-
clearCollapsedNodes
public void clearCollapsedNodes()
Clears the hidden expansion of all nodes, making all nodes expanded again.
-
clearHiddenTasks
public void clearHiddenTasks()
Clears the hidden state of all tasks, making all tasks visible again.
-
getAndClearBackupClearFlag
public boolean getAndClearBackupClearFlag()
Clears the flag, and returns its value before it was cleared.- Returns:
- The flag that indicates whether a backup exists that can be restored.
-
getAndClearUpdateSources
public boolean getAndClearUpdateSources()
-
getCollapsedNodes
public Set<NodeKey> getCollapsedNodes()
- Returns:
- A list of all workflow nodes that should be displayed as collapsed in the flowchart.
-
getElementMessagesMap
public Map<ElementKey,ElementMessageSetModel> getElementMessagesMap()
- Returns:
- List of messages for nodes and triggers, indexed by their key.
-
getFlowchartSelection
public FlowchartSelection<?> getFlowchartSelection()
- Returns:
- The currently selected node or trigger.
-
getHiddenTasks
public Set<UUID> getHiddenTasks()
- Returns:
- A list of all workflow tasks that should be hidden in the flowchart.
-
getHistoryInfo
public HistoryInfo getHistoryInfo()
- Returns:
- Data regarding the current redo / undo history of the flowchart.
-
getParamsMap
public Map<ElementKey,com.alibaba.fastjson.JSONObject> getParamsMap()
- Returns:
- The map with all custom parameters of nodes and triggers.
-
getProcessMessages
public ElementMessageSetModel getProcessMessages()
- Returns:
- All validation messages for the process.
-
getProcessModel
public ProcessModel getProcessModel() throws FastJsonException
- Returns:
- The current process model. Updates from the client are deserialized as necessary.
- Throws:
FastJsonException- When updates from the client could not be decoded.
-
getTaskByUuid
public TaskModel getTaskByUuid(UUID taskUuid) throws FastJsonException
- Parameters:
taskUuid- UIUD of a task.- Returns:
- The
TaskModelwith the given UUID,nullwhen no such task exists. - Throws:
FastJsonException- When updates from the client could not be decoded.
-
getTaskMessagesMap
public Map<UUID,ElementMessageSetModel> getTaskMessagesMap()
- Returns:
- List of messages for tasks, indexed by their UUID.
-
getVersion
public IVersionInfo getVersion()
- Returns:
- Current version of certain quantities, can be used to cache certain derived quanties.
-
isHasExternalStateChanged
public boolean isHasExternalStateChanged()
- Returns:
- Whether the external state has changed since the last update.
-
isShowLaneSeparators
public boolean isShowLaneSeparators()
- Returns:
- Whether the lines separating individual lanes should be displayed.
-
queueElementMessagesUpdate
public void queueElementMessagesUpdate(ElementKey key, ElementMessageSetModel messages)
Adds the given messages for a node or trigger to this model, and replaces all messages previously associated with that node or trigger. It transfers the updates to the client so that the flowchart gets updated.- Parameters:
key- Key of a node or trigger.messages- New messages for the given node or trigger.
-
queueParamsUpdate
public void queueParamsUpdate(ElementKey key, com.alibaba.fastjson.JSONObject customParams)
When the server wants to make changes to the custom parameters of aNodeModelorTriggerModel, this method needs to be used. It transfers the updates custom parameters to the client so that the flowchart gets updated.- Parameters:
key- Element for which to update the custom parameters.customParams- The new custom parameters for the node or trigger.
-
queuePatches
public void queuePatches(Collection<? extends JsonPatchUpdate> patches)
When the model on the client side has changed, the client sends a list of JSON patch-like objects so that the server can update its model. The patches may not be applied immediately, but it is guaranteed that they are applied transparently to the process model - i.e. the next timegetProcessModel()is called, it reflects the current state with all patches applied.- Parameters:
patches- The patches received from the client.
-
queueProcessMessagesUpdate
public void queueProcessMessagesUpdate(ElementMessageSetModel messages)
Adds the given messages for the process to this model, and replaces all messages previously associated with the process. It transfers the updates to the client so that the flowchart gets updated.- Parameters:
messages- New messages for the process.
-
queueSelectionUpdate
public void queueSelectionUpdate(FlowchartSelection<?> selection)
-
queueTaskMessagesUpdate
public void queueTaskMessagesUpdate(UUID key, ElementMessageSetModel messages)
Adds the given messages for a task to this model, and replaces all messages previously associated with that task. It transfers the updates to the client so that the flowchart gets updated.- Parameters:
key- Key of a task.messages- New messages for the given node or trigger.
-
queueUpdateSources
public void queueUpdateSources()
Update the drag sources, trigger add sources and node add sources on the client. Use this when you have made changes to the node or trigger prototypes.
-
requestClearBackup
public void requestClearBackup()
Clear the backup saved on the client. Usually set totrueafter the model was persisted. You will need to update the flowchart widget for this to take effect.
-
setFlowchartSelection
public void setFlowchartSelection(FlowchartSelection<?> selected)
- Parameters:
selected- The currently selected node or trigger.
-
setHideTask
public void setHideTask(UUID taskUuid, boolean hide)
By default all tasks are shown. You can use this method to hide a task in the flowchart.- Parameters:
taskUuid- UUID of a task-hide-trueto hide the task,falseto show it.
-
setNodeCollapsed
public void setNodeCollapsed(NodeKey nodeKey, boolean collapsed)
By default all nodes are expanded. You can use this method to collapse a task in the flowchart (if it supports it).- Parameters:
nodeKey- Key of a node.-collapsed-trueto collapse the node,falseto expand it.
-
setShowLaneSeparators
public void setShowLaneSeparators(boolean showLaneSeparators)
- Parameters:
showLaneSeparators- Whether the lines separating the lanes should be displayed or hidden.
-
updateElementMessages
public boolean updateElementMessages(ElementKey key, ElementMessageSetModel messages)
Inserts the given messages for the node or trigger.- Parameters:
key- Key of node or trigger.messages- Messages to set for that node or trigger.- Returns:
trueif anything was changed,falseif we already have the given messages.- See Also:
queueElementMessagesUpdate(ElementKey, ElementMessageSetModel)
-
updateElementMessages
public void updateElementMessages(Map<ElementKey,ElementMessageSetModel> messageMap)
Inserts the given messages for the node or trigger.- Parameters:
messageMap- Messages for nodes and trigger to add.
-
updateExternalState
public void updateExternalState(com.alibaba.fastjson.JSONObject externalState)
- Parameters:
externalState- External state that should be available within the flowchart preact state. Only values at keys contained in this object are updated on the client. That is, you can perform a partial update of the external state by just omitting the keys you do not wish to update.
-
updateHistoryInfo
public void updateHistoryInfo(HistoryInfo historyInfo)
Called by the flowchart. Should usually not be called manually.- Parameters:
historyInfo- New history info received from the flowchart.
-
updateParams
public boolean updateParams(ElementKey key, com.alibaba.fastjson.JSONObject customParams)
Replaces the custom node or trigger parameters with the given data.- Parameters:
key- Key of a node or trigger for which to the the custom parameters.customParams- New parameters for the node or trigger.- Returns:
trueif anything was changed,falseif nothing was changed.
-
updateProcessMessages
public void updateProcessMessages(ElementMessageSetModel messages)
Sets the given messages for the process.- Parameters:
messages- New messages for the process to set.
-
updateTaskMessages
public void updateTaskMessages(Map<UUID,ElementMessageSetModel> messageMap)
Inserts the given messages for the tasks.- Parameters:
messageMap- Messages for tasks to add.
-
updateTaskMessages
public void updateTaskMessages(UUID key, ElementMessageSetModel messages)
Inserts the given messages for a task.- Parameters:
key- UUID of a task.messages- Messages for the task add.
-
empty
public static FlowchartModel empty()
Creates a new flowchart model with the default for all values.- Returns:
- A new flowchart model with the defaults.
-
of
public static FlowchartModel of(ProcessModel processModel, Map<ElementKey,com.alibaba.fastjson.JSONObject> customParamsMap) throws FastJsonException
Creates a new flowchart model with the given data.- Parameters:
processModel- Process model to use.customParamsMap- Map with custom properties of nodes and triggers.- Returns:
- A new flowchart model with the given initial data and all other data set to defaults.
- Throws:
FastJsonException- When the custom params map could not be deserialized.
-
withMessages
public static FlowchartModel withMessages(ProcessModel processModel, Map<ElementKey,com.alibaba.fastjson.JSONObject> customParamsMap, ElementMessageSetModel processMessages, Map<UUID,ElementMessageSetModel> taskMessagesMap, Map<ElementKey,ElementMessageSetModel> elementMessagesMap) throws FastJsonException
Creates a new flowchart model with the given data.- Parameters:
processModel- Process model to use.customParamsMap- Map with custom properties of nodes and triggers.processMessages- Messages for the process.taskMessagesMap- Messages for tasks.elementMessagesMap- Messages for nodes and triggers.- Returns:
- A new flowchart model with the given initial data and all other data set to defaults.
- Throws:
FastJsonException- When the custom params map could not be deserialized.
-
-