<?xml version="1.0" encoding="UTF-8"?> 
<process xmlns="http://drools.org/drools-5.0/process"
         xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
         xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
         type="RuleFlow" name="ruleflow" id="com.sample.ruleflow" package-name="com.sample" >

  <header>
    <imports>
      <import name="org.kie.spring.beans.persistence.MyEntity" />
      <import name="org.kie.spring.beans.persistence.MyVariableSerializable" />
        <import name="javax.persistence.EntityManager" />
        <import name="org.kie.api.runtime.EnvironmentName" />
    </imports>
    <variables>
      <variable name="x" >
        <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
      </variable>
      <variable name="y" >
        <type name="org.jbpm.process.core.datatype.impl.type.ObjectDataType" className="org.kie.spring.beans.persistence.MyEntity" />
      </variable>
      <variable name="z" >
        <type name="org.jbpm.process.core.datatype.impl.type.ObjectDataType" className="org.kie.spring.beans.persistence.MyVariableSerializable" />
      </variable>
      <variable name="a" >
        <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
      </variable>
      <variable name="b" >
        <type name="org.jbpm.process.core.datatype.impl.type.ObjectDataType" className="org.kie.spring.beans.persistence.MyEntity" />
      </variable>
      <variable name="c" >
        <type name="org.jbpm.process.core.datatype.impl.type.ObjectDataType" className="org.kie.spring.beans.persistence.MyVariableSerializable" />
      </variable>
    </variables>
  </header>

  <nodes>
    <start id="1" name="Start" x="16" y="16" width="48" height="48" />
    <end id="3" name="End" x="458" y="189" width="48" height="48" />
    <humanTask id="4" name="Human Task" x="208" y="16" width="93" height="48" >
      <work name="Human Task" >
        <parameter name="ActorId" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Comment" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Content" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Priority" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Skippable" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="TaskName" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
      </work>
    </humanTask>
    <actionNode id="5" name="Action" x="96" y="20" width="80" height="40" >
        <action type="expression" dialect="java" >System.out.println("x = " + x);
System.out.println("y = " + y);
System.out.println("z = " + z);</action>
    </actionNode>
    <actionNode id="6" name="Action" x="333" y="20" width="80" height="40" >
        <action type="expression" dialect="java" >System.out.println("x = " + x);
System.out.println("y = " + y);
System.out.println("z = " + z);
kcontext.setVariable("a", "Some new String");

EntityManager em = (EntityManager) kcontext.getKnowledgeRuntime().getEnvironment().get(EnvironmentName.APP_SCOPED_ENTITY_MANAGER);
MyEntity myNewEntity = new MyEntity("This is a new test Entity");
em.persist(myNewEntity);


kcontext.setVariable("b", myNewEntity);
kcontext.setVariable("c", new MyVariableSerializable("This is a new test SerializableObject"));</action>
    </actionNode>
    <humanTask id="7" name="Human Task" x="445" y="20" width="80" height="40" >
      <work name="Human Task" >
        <parameter name="ActorId" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Comment" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Content" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Priority" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Skippable" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="TaskName" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
      </work>
    </humanTask>
    <actionNode id="8" name="Action" x="557" y="20" width="80" height="40" >
        <action type="expression" dialect="java" >System.out.println("x = " + x);
System.out.println("y = " + y);
System.out.println("z = " + z);
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);
kcontext.setVariable("a", "Some changed String");
EntityManager em = (EntityManager) kcontext.getKnowledgeRuntime().getEnvironment().get(EnvironmentName.APP_SCOPED_ENTITY_MANAGER);
MyEntity myNewEntity = new MyEntity("This is a changed test Entity");
em.persist(myNewEntity);

kcontext.setVariable("b", myNewEntity);
kcontext.setVariable("c", new MyVariableSerializable("This is a changed test SerializableObject"));</action>
    </actionNode>
    <humanTask id="9" name="Human Task" x="550" y="94" width="100" height="48" >
      <work name="Human Task" >
        <parameter name="ActorId" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Comment" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Content" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Priority" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="Skippable" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
        <parameter name="TaskName" >
          <type name="org.jbpm.process.core.datatype.impl.type.StringDataType" />
        </parameter>
      </work>
    </humanTask>
    <actionNode id="10" name="Action" x="562" y="189" width="80" height="48" >
        <action type="expression" dialect="java" >System.out.println("x = " + x);
System.out.println("y = " + y);
System.out.println("z = " + z);
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);</action>
    </actionNode>
  </nodes>

  <connections>
    <connection from="10" to="3" />
    <connection from="5" to="4" />
    <connection from="1" to="5" />
    <connection from="4" to="6" />
    <connection from="6" to="7" />
    <connection from="7" to="8" />
    <connection from="8" to="9" />
    <connection from="9" to="10" />
  </connections>

</process>
