Class JobActionUtils


  • public class JobActionUtils
    extends Object
    Provides a utility class with common methods called by Job Action Services.
    Since:
    4.0.0
    • Field Detail

      • PROPERTY_PROCESS_MESSAGE_TEXT

        public static final String PROPERTY_PROCESS_MESSAGE_TEXT
        The processing message text.
        See Also:
        Constant Field Values
      • PROPERTY_PROCESS_MESSAGE_SUBMISSION

        public static final String PROPERTY_PROCESS_MESSAGE_SUBMISSION
        The processing message submission.
        See Also:
        Constant Field Values
      • PROPERTY_PROCESS_MESSAGE_SUBMISSION_STEP

        public static final String PROPERTY_PROCESS_MESSAGE_SUBMISSION_STEP
        The processing message submission step.
        See Also:
        Constant Field Values
      • PROPERTY_PROCESS_MESSAGE_SEND_EMAIL

        public static final String PROPERTY_PROCESS_MESSAGE_SEND_EMAIL
        The processing message send email.
        See Also:
        Constant Field Values
      • PROPERTY_PROCESS_MESSAGE_EMAIL_TO

        public static final String PROPERTY_PROCESS_MESSAGE_EMAIL_TO
        The processing message email to.
        See Also:
        Constant Field Values
      • PROPERTY_PROCESS_MESSAGE_EMAIL_SUBJECT_TEMPLATE

        public static final String PROPERTY_PROCESS_MESSAGE_EMAIL_SUBJECT_TEMPLATE
        The processing message email message template name.
        See Also:
        Constant Field Values
      • PROPERTY_PROCESS_MESSAGE_EMAIL_MESSAGE_TEMPLATE

        public static final String PROPERTY_PROCESS_MESSAGE_EMAIL_MESSAGE_TEMPLATE
        The processing message email message template name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JobActionUtils

        public JobActionUtils()
    • Method Detail

      • getThreadAssignRepeatIndex

        public static Integer getThreadAssignRepeatIndex()
        Return the thread local Task Assign Repeat Index value [1..n].
        Returns:
        the thread local Task Assign Repeat Index value [1..n]
        Since:
        4.1.8
      • setThreadAssignRepeatIndex

        public static void setThreadAssignRepeatIndex​(Integer index)
        Set the thread local Task Assign Repeat Index value [1..n].
        Parameters:
        index - set the thread local Task Assign Repeat Index value [1..n]
        Since:
        4.1.8
      • getThreadAssignRepeatItem

        public static String getThreadAssignRepeatItem()
        Return the thread local Task Assign Repeat Item.
        Returns:
        the thread local Task Assign Repeat Item
        Since:
        4.1.8
      • setThreadAssignRepeatItem

        public static void setThreadAssignRepeatItem​(String item)
        Set the thread local Task Assign Repeat Item.
        Parameters:
        item - the thread local Task Assign Repeat Item
        Since:
        4.1.8
      • getFormStartSubmission

        public static Submission getFormStartSubmission​(JobAction currentJobAction)
        Gets the original submission that started the Job's form start action.
        Parameters:
        currentJobAction - the JobAction associated with the Job Action Service.
        Returns:
        if found returns the original submission associated with the FormStart Action
      • getFormDataMapRefs

        public static Set<String> getFormDataMapRefs​(String jsonString)
        Return the set of formDataMap references in the JSON string.
        Parameters:
        jsonString - the JSON string to parse (required)
        Returns:
        the set of formDataMap references in the JSON string
        Since:
        4.2.0
      • getPreviousSubmission

        public static Submission getPreviousSubmission​(JobAction currentJobAction)
        Gets the submission from the previous step action.
        Parameters:
        currentJobAction - the JobAction associated with the Job Action Service.
        Returns:
        if found returns the previous step submission
      • getLastSubmission

        public static Submission getLastSubmission​(ActionContext actionContext,
                                                   String stepName)
        Gets the submission for the specified step name working backwards from latest to earliest steps.
        Parameters:
        actionContext - the ActionContext associated with the Job Action Service.
        stepName - the step name that you want to retrieve the submission from.
        Returns:
        if found returns the submission for the specified step name working backwards from latest to earliest steps
      • getRedirectNextTask

        public static Submission getRedirectNextTask​(Submission submission)
        Get the next task to redirect the user to for an Application Bundle workflow.
        Parameters:
        submission - the current submission being processed (required)
        Returns:
        the next task to redirect the user to, or null if not defined
        Since:
        4.3.0
      • getLastStep

        public static JobStep getLastStep​(Job job,
                                          String stepName)
        Gets the latest step instance for the specified step name working backwards from latest to earliest steps.
        Parameters:
        job - the job containing the step
        stepName - the step name that you want to retrieve the step for.
        Returns:
        if found returns the latest step instance with that stepName
        Since:
        4.2.0
      • getFirstStep

        public static JobStep getFirstStep​(Job job,
                                           String stepName)
        Gets the earliest step instance for the specified step name working forwards from earliest to latest steps.
        Parameters:
        job - the job containing the step instance
        stepName - the step name that you want to retrieve the step instance
        Returns:
        if found returns the first step instance with that stepName
        Since:
        4.2.0
      • getPreviousStep

        public static JobStep getPreviousStep​(Job job)
        Return the previous step relative to the job's current step, or null if current step is first step.
        Parameters:
        job - the job to get the previous step from
        Returns:
        the previous step, or null if the current step is the first step in a job
        Since:
        4.3.0
      • getStepSubmission

        public static Submission getStepSubmission​(Job job,
                                                   String stepName)
        Return the first submission for the given step name or null if not found.
        Parameters:
        job - the job (required)
        stepName - the job step name (required)
        Returns:
        the first submission for the given step name or null if not found
      • getSubmissionsForStep

        public static List<Submission> getSubmissionsForStep​(Job job,
                                                             String stepName)
        Returns a List of submissions, in id order, for the job and given step name or and empty List
        Parameters:
        job - the job (required)
        stepName - the job step name (required)
        Returns:
        a List of submissions in id order for the given step name otherwise and empty List
        Since:
        4.1.0
      • getSubmissionsForLastStep

        public static List<Submission> getSubmissionsForLastStep​(Job job,
                                                                 String stepName)
        Returns a List of submissions, in action order, for the latest job step and given step name or and empty List
        Parameters:
        job - the job (required)
        stepName - the job step name (required)
        Returns:
        a List of submissions in id order for the given step name otherwise and empty List
        Since:
        4.1.0
      • getSubmissionsForStep

        public static List<Submission> getSubmissionsForStep​(JobStep step)
        Returns a List of submissions, in action order, for the given job step or and empty List
        Parameters:
        step - the JobStep that holds the submissions (required)
        Returns:
        a List of submissions in id order for the given step name otherwise and empty List
        Since:
        4.1.10
      • getCompletedSubmissionsForStep

        public static List<Submission> getCompletedSubmissionsForStep​(JobStep step)
        Returns a List of completed submissions for the step, in id order, for the given job step or and empty List
        Parameters:
        step - the JobStep that holds the submissions (required)
        Returns:
        a List of completed submissions for the step, in id order, for the given job step or and empty List
        Since:
        4.3.0
      • getFormStartUser

        public static UserAccount getFormStartUser​(JobAction currentJobAction)
        Returns the user that made the original submission. This is associated with the Job's Form Start Action
        Parameters:
        currentJobAction - the JobAction associated with the Job Action Service.
        Returns:
        if found returns the user associated with the original submission otherwise null
      • addSubmissionProcessingStatus

        public static void addSubmissionProcessingStatus​(ActionContext actionContext,
                                                         ActionStepProperties actionStepProperties,
                                                         Submission submission)
        Add processing status message to the submission.
        Parameters:
        actionContext - the actionContext for the JobAction (required)
        actionStepProperties - the ActionStepProperties for a particular JobAction instance (required)
        submission - the submission to provide a processing status message to (optional)
      • getFormDataMapPreviousStep

        public static Map<String,​String> getFormDataMapPreviousStep​(JobAction currentJobAction)
        Returns the formDataMap for the previous JobStep submission
        Parameters:
        currentJobAction - the current JobAction
        Returns:
        the formDataMap Map<String, String> for the submission on a previous step
      • getFormDataMap

        public static Map<String,​String> getFormDataMap​(Submission submission)
        Returns the formDataMap for the current submission
        Parameters:
        submission - the Submission that you want the formDataMap from
        Returns:
        the formDataMap Map<String, String> associated to the the
      • validatePropertyNotBlank

        public static String validatePropertyNotBlank​(ActionStepProperties actionStepProperties,
                                                      String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is not blank.
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is blank, or null otherwise
      • validatePropertyIsDate

        public static String validatePropertyIsDate​(ActionStepProperties actionStepProperties,
                                                    String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a date value if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is date value if defined, or null otherwise
      • validatePropertyIsDouble

        public static String validatePropertyIsDouble​(ActionStepProperties actionStepProperties,
                                                      String propertyName)
        Deprecated.
        Validate the given actionStepProperties ensuring the given propertyName value is a Integer value if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is a Integer value if defined, or null otherwise
      • validatePropertyIsInteger

        public static String validatePropertyIsInteger​(ActionStepProperties actionStepProperties,
                                                       String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a Integer value if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is a Integer value if defined, or null otherwise
      • validatePropertyIsBoolean

        public static String validatePropertyIsBoolean​(ActionStepProperties actionStepProperties,
                                                       String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a boolean value if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is a boolean value if defined, or null otherwise
      • validatePropertyIsStep

        public static String validatePropertyIsStep​(ActionStepProperties actionStepProperties,
                                                    String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a valid Step name if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is a valid Step name if defined, or null otherwise
      • validatePropertyIsEmail

        public static String validatePropertyIsEmail​(ActionStepProperties actionStepProperties,
                                                     String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a valid email if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is a valid email if defined, or null otherwise
      • validatePropertyIsFormCode

        public static String validatePropertyIsFormCode​(ActionStepProperties actionStepProperties,
                                                        String propertyName,
                                                        Client client)
        Deprecated.
        use validatePropertyIsForm.
        Validate the given actionStepProperties ensuring the given propertyName value is a valid form code if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name
        client - the client organization
        Returns:
        the validation error message if the specified property is a valid Step name if defined, or null otherwise
      • validatePropertyIsForm

        public static String validatePropertyIsForm​(ActionStepProperties actionStepProperties,
                                                    String formCodePropertyName,
                                                    Client client,
                                                    String versionPropertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a valid form code if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        formCodePropertyName - the property name for the form code to test
        client - the client organization
        versionPropertyName - the property name for the form version to test
        Returns:
        the validation error message if the specified property is a valid Step name if defined, or null otherwise
        Since:
        5.1.0
      • validatePropertyIsPortal

        public static String validatePropertyIsPortal​(ActionStepProperties actionStepProperties,
                                                      String propertyName,
                                                      Client client)
        Validate the given actionStepProperties ensuring the given propertyName value is a Portal if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        client - the client organization
        Returns:
        the validation error message if the specified property is a Portal if defined, or null otherwise
      • validatePropertyIsGroup

        public static String validatePropertyIsGroup​(ActionStepProperties actionStepProperties,
                                                     String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a Group if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is a Group if defined, or null otherwise
      • validatePropertyIsFormGroupNames

        public static String validatePropertyIsFormGroupNames​(ActionStepProperties actionStepProperties,
                                                              String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a set of valid form group names
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is set of valid form group names if defined, or null otherwise
        Since:
        4.1.0
      • validatePropertyIsUser

        public static String validatePropertyIsUser​(ActionStepProperties actionStepProperties,
                                                    String propertyName)
        Validate the given actionStepProperties ensuring the given propertyName value is a User if defined
        Parameters:
        actionStepProperties - the action step properties to validate
        propertyName - the property name to test
        Returns:
        the validation error message if the specified property is a User if defined, or null otherwise
      • convertNumericPropertyValues

        public static Map<String,​Object> convertNumericPropertyValues​(Map<String,​String> inputMap)
        Return a Map with the numeric string property values converted to Integer, Long or Double.
        Parameters:
        inputMap - the property name value map
        Returns:
        a Map<String, Object> with property values converted to Integer, Long or Double
      • isDynamicProperty

        public static boolean isDynamicProperty​(String propertyValue)
        Return true if property value is dynamically resolved or false if a static literal property value.
        Parameters:
        propertyValue - the property value to test (required)
        Returns:
        true if property value is dynamically resolved or false if a static literal property value
        Since:
        4.1.0
      • expireStepTasksAndActions

        public static ActionResult expireStepTasksAndActions​(JobAction expiryJobAction,
                                                             String expiryRouteName)
        Called from an Job Expiry service this will expire the tasks and actions for a job.
        Parameters:
        expiryJobAction - the expiry service JobAction
        expiryRouteName - the route name that is returned in the ActionResult
        Returns:
        ActionResult with the route name set as the expiryRouteName
        Since:
        4.3.2
      • getRouteName

        public static String getRouteName​(Submission submission)
        Returns the route name from the given submission. If blank then attempt to lookup in //SystemProfile/Job/RouteName.
        Parameters:
        submission - the submission associated with a Job / JobAction. The submission needs to be associated with a job and the submission.getFormStatus() cannot be null.
        Returns:
        the route name from the given submission
        Since:
        4.3.4
      • toJobHistoryJsonString

        public static String toJobHistoryJsonString​(Job job)
        Return the job JSON debug representation of this object for debugging purposes.
        Parameters:
        job - the job to print out
        Returns:
        the job JSON debug representation of this object for debugging purposes
        Since:
        5.1.0