Class WorkflowCustomParametersHelper


  • public class WorkflowCustomParametersHelper
    extends Object
    Helper class for serializing and deserializing the custom properties model of workflow nodes and triggers, see ICustomParametersProviding.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • deserializeCustomProps

        public static <TData,​TElement extends IWorkflowElementEntity> TData deserializeCustomProps​(com.alibaba.fastjson.JSONObject json,
                                                                                                         IElementHandler<TData,​TElement> handler)
        Takes the serialized JSON properties model of a workflow element, deserializes it according to the given handler, and returns the deserialized properties model.
        Parameters:
        json - The properties model in serialized form.
        handler - Handler to use for deserialization.
        Returns:
        The properties model, deserialized according to the given handler.
      • deserializeCustomProps

        public static <TData,​TElement extends IWorkflowElementEntity> TData deserializeCustomProps​(TElement element,
                                                                                                         IElementHandler<TData,​TElement> handler,
                                                                                                         Mandant client)
        Takes the serialized JSON custom parameters of the given node, and returns the deserialized properties model.
        Parameters:
        element - Workflow element to process.
        handler - Logic handler to use for the deserialization.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The deserialized custom properties of the given node.
      • deserializeCustomProps

        public static <TElement extends IWorkflowElementEntityObject deserializeCustomProps​(TElement element,
                                                                                              Mandant client)
        Takes the serialized JSON custom parameters of the given node, and returns the deserialized properties model.
        Parameters:
        element - Workflow element to process.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The deserialized custom properties of the given node.
      • eachNode

        public static Iterable<WorkflowNode> eachNode​(WorkflowNode startNode,
                                                      Mandant client)
        Parameters:
        startNode - Node at which to start the iteration.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        An iterable over the (sub) tree at the given node, including the node itself.
      • retrieveCustomParams

        public static <TElement extends IWorkflowElementEntity> com.alibaba.fastjson.JSONObject retrieveCustomParams​(TElement element,
                                                                                                                     Mandant client)
        Retrieves the deserialized custom properties of a node or trigger, making sure to update the properties to the current version.
        Type Parameters:
        TElement - Type of the workflow element, i.e. a node or trigger.
        Parameters:
        element - Element with custom properties.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The updated, deserialized custom properties of the node or trigger.
      • serializeCustomProps

        public static com.alibaba.fastjson.JSONObject serializeCustomProps​(Object data,
                                                                           IWorkflowElementEntity element,
                                                                           Mandant client)
        Serializes the custom properties of a workflow element and set the result on the element via IWorkflowElementEntity.setCustomParameters(String).
        Parameters:
        data - Data to serialize.
        element - Element from the data originates.
        client - Client for retrieving the element handler.
        Returns:
        The serialized JSON.
      • serializeCustomProps

        public static <TData,​TElement extends IWorkflowElementEntity> com.alibaba.fastjson.JSONObject serializeCustomProps​(TData data,
                                                                                                                                 IElementHandler<TData,​TElement> handler)
        Serializes the custom properties of a workflow element and set the result on the element via IWorkflowElementEntity.setCustomParameters(String).
        Type Parameters:
        TData - Type of the element's properties model.
        TElement - Type of the element.
        Parameters:
        data - Data to serialize.
        handler - Handler for the element type.
        Returns:
        The serialized JSON.
      • serializeCustomPropsToString

        public static <TData,​TElement extends IWorkflowElementEntityString serializeCustomPropsToString​(TData data,
                                                                                                                IElementHandler<TData,​TElement> handler)
        Serializes the custom properties of a workflow element and set the result on the element via IWorkflowElementEntity.setCustomParameters(String).
        Type Parameters:
        TData - Type of the element's properties model.
        TElement - Type of the element.
        Parameters:
        data - Data to serialize.
        handler - Handler for the element type.
        Returns:
        The serialized JSON.
      • serializeCustomPropsToString

        public static <TData,​TElement extends IWorkflowElementEntityString serializeCustomPropsToString​(TData data,
                                                                                                                TElement element,
                                                                                                                Mandant client)
        Serializes the custom properties of a workflow element and set the result on the element via IWorkflowElementEntity.setCustomParameters(String).
        Type Parameters:
        TData - Type of the element's properties model.
        TElement - Type of the element.
        Parameters:
        data - Data to serialize.
        element - Element from the data originates.
        client - Client for retrieving the element handler.
        Returns:
        The serialized JSON.
      • setCustomProps

        public static <TData,​TElement extends IWorkflowElementEntity> void setCustomProps​(TData data,
                                                                                                TElement element,
                                                                                                IElementHandler<TData,​TElement> handler)
        Serializes the custom properties of a workflow element and set the result on the element via IWorkflowElementEntity.setCustomParameters(String).
        Type Parameters:
        TData - Type of the element's properties model.
        TElement - Type of the element.
        Parameters:
        data - Data to serialize and set on the element.
        element - Element on which to set the data.
        handler - Handler for the element type.
      • toJson

        public static com.alibaba.fastjson.JSONObject toJson​(Object data,
                                                             IWorkflowElementTypeProviding element,
                                                             Mandant client)
                                                      throws FastJsonException
        Takes the deserialized properties model of a workflow element and serializes it to JSON.
        Parameters:
        data - Custom properties model to serialize.
        element - Type of the element for retrieving the handler.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The properties model, serialized to JSON according to the handler of the given element type.
        Throws:
        FastJsonException - When the JSON could not be converted.
      • toJson

        public static <TData> com.alibaba.fastjson.JSONObject toJson​(TData data,
                                                                     IElementHandler<TData,​?> handler)
                                                              throws FastJsonException
        Takes the deserialized properties model of a workflow element and serializes it to JSON.
        Type Parameters:
        TData - Type of the properties model.
        Parameters:
        data - Custom properties model to serialize.
        handler - Handler to be used for serialization..
        Returns:
        The properties model, serialized to JSON according to the given handler.
        Throws:
        FastJsonException - When the JSON could not be converted.
      • toJsonString

        public static <TData> String toJsonString​(TData data,
                                                  IElementHandler<TData,​?> handler)
                                           throws FastJsonException
        Takes the deserialized properties model of a workflow element and serializes it to JSON.
        Parameters:
        data - Custom properties model to serialize.
        handler - Handler to be used for serialization..
        Returns:
        The properties model, serialized to JSON according to the given handler.
        Throws:
        FastJsonException - When the JSON could not be converted.
      • transferToDataModel

        public static WorkflowNode transferToDataModel​(WorkflowNode node,
                                                       com.alibaba.fastjson.JSONObject customParams,
                                                       Object data,
                                                       Mandant client)
        Extract the relevant data from the node's properties model and set the data on the WorkflowNode.
        Parameters:
        node - The node on which to set the data.
        customParams - Serialized and updated properties model.
        data - Deserialized properties model.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The node as it was passed in, with the data set.
        See Also:
        transferToDataModel(WorkflowNode, Mandant)
      • transferToDataModel

        public static WorkflowNode transferToDataModel​(WorkflowNode node,
                                                       Mandant client)
        Extract the relevant data from the node's properties model and set the data on the WorkflowNode.
        Parameters:
        node - The node on which to set the data.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The node as it was passed in, with the data set.
      • transferToDataModel

        public static WorkflowTrigger transferToDataModel​(WorkflowTrigger trigger,
                                                          com.alibaba.fastjson.JSONObject customParams,
                                                          Object data,
                                                          Mandant client)
        Extract the relevant data from the triggers's properties model and set the data on the WorkflowTrigger.
        Parameters:
        trigger - The trigger on which to set the data.
        customParams - Serialized properties model.
        data - Deserialized properties model.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The trigger as it was passed in, with the data set.
      • transferToDataModel

        public static <TElement extends AWorkflowElement<?,​?>> TElement transferToDataModel​(TElement element,
                                                                                                  com.alibaba.fastjson.JSONObject customParams,
                                                                                                  Object data,
                                                                                                  Mandant client)
        Extract the relevant data from the element's properties model and set the data on the AWorkflowElement.
        Parameters:
        element - The element on which to set the data.
        customParams - Serialized properties model.
        data - Deserialized properties model.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The element as it was passed in, with the data set.
      • transferToDataModel

        public static WorkflowTrigger transferToDataModel​(WorkflowTrigger trigger,
                                                          Mandant client)
        Extract the relevant data from the triggers's properties model and set the data on the WorkflowTrigger.
        Parameters:
        trigger - The trigger on which to set the data.
        client - The client scope where this method is called. Required for accessing client-scope handler plugins.
        Returns:
        The trigger as it was passed in, with the data set.
      • updateCustomParams

        public static com.alibaba.fastjson.JSONObject updateCustomParams​(com.alibaba.fastjson.JSONObject json,
                                                                         IElementHandler<?,​?> handler)
        Updates the serialized JSON properties of the node or trigger. Checks the version of the properties (an entry in the JSON object with the name CmnConst.Workflow.PARAMS_KEY_VERSION), and if different from the current version, locates the handler class for the for workflow element, and invokes its ICustomParametersUpdateable.updateCustomParams(IUpdateCustomParametersParams) method.
        Parameters:
        json - Properties to update.
        handler - Handler class of the node or trigger.
        Returns:
        The updated properties.