Difference between revisions of "Examples: Process Handler"

From OpenKM Documentation
Jump to: navigation, search
(Process handlers)
 
(One intermediate revision by the same user not shown)
Line 54: Line 54:
 
public class FechaHandler implements ActionHandler {
 
public class FechaHandler implements ActionHandler {
 
     private static final long serialVersionUID = 1L;
 
     private static final long serialVersionUID = 1L;
 
+
   
 +
    @Override
 
     public void execute(ExecutionContext context) throws Exception {
 
     public void execute(ExecutionContext context) throws Exception {
 
         Input myFecha = new Input();
 
         Input myFecha = new Input();
Line 99: Line 100:
  
 
[[Category: Workflow Guide]]
 
[[Category: Workflow Guide]]
[[Category:OKM Network]]
 

Latest revision as of 12:50, 3 December 2012

Download and test this process definition: File:Phandler.par.


Nota clasica.png The taks will be assigned to an user called "openkm" so you need to create this user and log as him to see the task assignment. Also you can assing this task to another user from the process instance workflow administration.

Process image

Workflow example process handler.png

Process definition

<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="phandler">
   <start-state name="inicio">
      <transition to="entrada de documentos">
         <action class="com.openkm.sample.FechaHandler"></action>
      </transition>
   </start-state>

   <task-node name="entrada de documentos">
      <task name="Recepcion de Documentos">
         <assignment actor-id="openkm"></assignment>
      </task>
      <event type="node-enter">
         <script>
            print(&quot; ent_fecha &quot;)
         </script>
      </event>
      <transition to="enviar notificacion">
         <action class=""></action>
      </transition>
   </task-node>

   <mail-node name="enviar notificacion">
      <transition to="fin"></transition>
   </mail-node>

   <end-state name="fin"></end-state>
</process-definition>

Process handlers

package com.openkm.sample;

import java.util.Calendar;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import com.openkm.bean.form.Input;
import com.openkm.util.ISO8601;

public class FechaHandler implements ActionHandler {
    private static final long serialVersionUID = 1L;
    
    @Override
    public void execute(ExecutionContext context) throws Exception {
        Input myFecha = new Input();
        myFecha.setName("ent_fecha");
        myFecha.setValue(ISO8601.format(Calendar.getInstance()));
        context.getContextInstance().setVariable("ent_fecha", myFecha);
    }
}

Form definition

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE workflow-forms PUBLIC "-//OpenKM//DTD Workflow Forms 2.0//EN"
                                "http://www.openkm.com/dtd/workflow-forms-2.0.dtd">
<workflow-forms>    
  <workflow-form task="Recepcion de Documentos"> 
    <separator label="REGISTRO DE ENTRADA" name="sep_grp_entrada"/>
    
    <input label="No." name="ent_id"/>
    <input label="Fecha" name="ent_fecha" type="date" data="ent_fecha" readonly="true"/>
    <select label="Medio" name="ent_medio" type="simple">
      <option label="Correo" value="correo" selected="true"/>
      <option label="Email" value="email" />
      <option label="Fax" value="fax" />
      <option label="Mensajeria" value="mensajeria" />
      <option label="Propia Mano" value="propia mano" />
    </select>
    
    <separator label="DOCUMENTO" name="sep_doc"/>      
    
    <input label="No." name="ent_no_doc"/>
    <input label="Fecha" name="ent_fecha_doc" type="date"/>
    <textarea label="Asunto" name="ent_asunto" value=""/>
    
    <separator label="OBSERVACIONES" name="sep_obs"/>
    
    <textarea label="Observaciones" name="ent_obs" value=""/>
    <input label="Capturo" name="ent_capturo"/>
    <button label="Aceptar" name="ent_aceptar"/>
  </workflow-form>
</workflow-forms>