Package com.groiss.wf

Class SystemAction

java.lang.Object
com.groiss.wf.SystemAction

public class SystemAction extends Object
This class provides some methods useful for preprocessing and postconditions.
  • Constructor Details

    • SystemAction

      public SystemAction()
  • Method Details

    • lock

      public boolean lock(String name)
      Add a lock to the process instance. Must be eventually unlocked via unlock(String).
      Parameters:
      name - name of the lock
      Returns:
      always true
    • unlock

      public boolean unlock(String name)
      Removes the lock.
      Parameters:
      name - name of the lock
      Returns:
      always true
    • lockForCurrentTransaction

      public boolean lockForCurrentTransaction(String name)
      Add a lock to the process instance. Is automatically removed at transaction completion.
      Parameters:
      name - name of the lock
      Returns:
      always true
    • cancelActivity

      public void cancelActivity(String name)
      Cancel the activity: finishes the activity with the given task id
      Parameters:
      name - the id of a task
    • cancelProcess

      public void cancelProcess()
      Cancel the whole process. Note, that this method will work in task preprocessing but cannot be used in a system step.
    • autoTake

      public void autoTake() throws Exception
      This method performs a take when the activity instance is assigned to a role and there is exactly one user having this role. Please take note of substitutions, because roles can be inherited!
      Throws:
      Exception
    • log

      public boolean log(String message, String level)
      Writes the argument on the log.
      Parameters:
      message - the message
      level - the log level: error, warn, info, debug, trace
      Returns:
      true
    • setFieldToAgent

      public void setFieldToAgent(String formfield)
      Set a form field to the current user.
      Parameters:
      formfield - the form field: formid "." fieldame
    • setFieldToOU

      public void setFieldToOU(String formfield)
      Set a form field to the home org unit of agent
      Parameters:
      formfield - the form field: formid "." fieldame
    • setFieldToCurrentDate

      public void setFieldToCurrentDate(String formfield)
      Set a form field to the current date.
      Parameters:
      formfield - the form field: formid "." fieldame
    • getFormFieldValue

      public Object getFormFieldValue(String formfield)
      Returns the value of a formfield.
      Parameters:
      formfield - in the syntax formid "." fieldname
      Returns:
      the value object
    • setFieldToValue

      public void setFieldToValue(String formfield, String value) throws Exception
      Set a form field to specified value.
      Parameters:
      formfield - the form field: formid "." fieldname
      Throws:
      Exception
    • isStartAgent

      public boolean isStartAgent(String formfield)
      This method returns true, if the formfield contains a user object and the user is the start agent of the current process.
      Parameters:
      formfield - the form field in syntax: formid "." fieldame
    • isActive

      public boolean isActive(String task)
      Returns true, if there is an active or idle or suspended activity instance in the current process that has the task with the given id.
      Parameters:
      task - the id of a task object
      Returns:
      true if there is an active task
    • join

      public void join(String n, String mode)
      Expression in andjoin for implementing generalized andjoin.
      Parameters:
      n - number of branches that must be completed
      mode - either cancel or none. every other value is taken as none
    • parforJoin

      public void parforJoin(String n, String mode)
      Expression in end parfor for implementing generalized parfor join.
      Parameters:
      n - number of branches that must be completed
      mode - either cancel or none. every other value is taken as none
    • finishActivity

      public void finishActivity(String label)
      Finish a task, an andpar, orpar, or a parfor.
      Parameters:
      label - the label of a step
    • setAgentFromField

      public void setAgentFromField(String formfield)
      Set the current agent from a form field.
      Parameters:
      formfield - the form field: formid "." fieldame
    • isTrue

      public boolean isTrue()
      Use as condition dummy, always returns true.
    • isFalse

      public boolean isFalse()
      Use as condition dummy, returns false.
    • nop

      public void nop()
      Use as system step dummy, does nothing.
    • manualIf

      public boolean manualIf()
      Use this method in a condition if you want to select the result manually.
    • evaluateXPath

      public Object evaluateXPath(String xpathExpression)
      Evaluates the given XPath 1.0 expression.
      Parameters:
      xpathExpression -
      Returns:
      the result of the XPath-expression
    • increasePriority

      public void increasePriority(String offset)
      Increase the priority with an offset. Can be used as escalation action.
    • untake

      public void untake()
      Untake the task. Can be used as escalation action for tasks.
    • setDuedateFromField

      public void setDuedateFromField(String formfield) throws Exception
      Set the duedate of the current task to the value of the given form field.
      Throws:
      Exception
    • setProcessDuedateFromField

      public void setProcessDuedateFromField(String formfield) throws Exception
      Set the duedate of the current process instance to the value of the given form field.
      Throws:
      Exception
    • fourEyesPrinciple

      public void fourEyesPrinciple(String stepid)
      Check, if the current agent is not the agent of the step referenced by stepid. If the check fails an appropriate exception will be thrown.
      Parameters:
      stepid - the id of the step to check
    • fourEyesPrinciple

      public void fourEyesPrinciple(String stepid, ActivityInstance ai)
      Check, if the current agent is not the agent who did the last step instance of the step identified by the passed label. If the check fails an appropriate exception will be thrown.
      Parameters:
      stepid - the label of the step to check
      ai - the activity instance for which the check is performed
    • setOUFromField

      public boolean setOUFromField(String formfield, String forProcess)
      Set the org-unit of the current activity and optionally the process (parent) of the activity from a form field.
      Parameters:
      formfield - the form field: formid "." fieldame containing an org-unit
      forProcess - if value is true the org-unit of the parent of the activity-instance is also set to the given org-unit
    • randomTrue

      public boolean randomTrue(String percent)
      Returns true randomly.
      Parameters:
      percent - either an integer number giving the percentage of true results or the name of a configuration parameter defining the percentage.
      Returns:
    • sendMessage

      public void sendMessage(String templateid) throws Exception
      Send a message using a pre-defined message template. The mail is sent in a separate transaction after commit of this one.
      Parameters:
      templateid - the id of the message template
      Throws:
      Exception
    • getPreviousAgent

      public Object getPreviousAgent(String stepid, String defaultId)
      Get the agent of a previous step (identified by its label). If the step has not been executed before, use the defaultId - either a role or user id.
      Parameters:
      stepid - label of a step in the process
      defaultId - role or user id
      Returns:
      if a previous step is found, its agent else if the defaultId is not empty the defaultId else null.
    • getPreviousAgent

      public Object getPreviousAgent(String stepid, String defaultId, ActivityInstance ai)
    • httpGet

      public void httpGet(String urlstr, String returnfield) throws IOException
      Make a get request to a HTTP URL.
      Parameters:
      urlstr - use substitutions like in
      returnfield - a form field to write the return value
      Throws:
      IOException
    • addSubform

      public void addSubform(String form, String id) throws Exception
      Add a subform.
      Parameters:
      form - id of the main form
      id - id of the subform relation (parsed to an integer)
      Throws:
      Exception
    • suspend

      public void suspend(String days)
      Suspend the current activity instance.
    • executeReport

      public void executeReport(String id, String action, String target)
      Execute a report and store the result document. The process id is provided to the report as parameter "pid".
      Parameters:
      id - id of report
      action - email, dms or file
      target - message template, dms folder, or path. if action is dms and no target is given, the target is the folder of the process instance.
    • startProcess

      public ProcessInstance startProcess(String id, String orgUnit, String form1, String form2)
      Start a process.
      Parameters:
      id - the id of the process to start
      orgUnit - the org-unit of the process
      form1 - a comma separated list of form fields of the current process: the values are copied to the respective fields in form2, subforms can be copied by specifying <formid>.<subformid>
      form2 - a comma separated list of formfields of the new process, leave it empty if it is the same as form1
    • exportDocument

      public void exportDocument(String docpath, String filepath) throws Exception
      Copy a document form process folder to the file system.
      Parameters:
      docpath - path to a document of the process
      filepath - path in filesystem (absolute or relative to ep directory).
      Throws:
      Exception
    • addDocument

      public void addDocument(String origin, String filepath, String docpath) throws Exception
      Add a document to the process folder.
      Parameters:
      origin - dms or file
      filepath - path in filesystem or dms, see DMS.getDMSObject(String) for syntax of path
      docpath - path to the document
      Throws:
      Exception
    • addFolder

      public void addFolder(String name)
      add a folder to the process.
      Parameters:
      name - name of the folder