4 Replies Latest reply on Mar 10, 2010 6:10 PM by jochen_mader

    Converting a variable back

    jochen_mader

      I am working on jBPM 4.3.

      I wrote a converter to convert one of my classes into a Long (it's coming from JPA with the Long being its key).

      I added it to jbpm.variables.types.xml and using the following code I add the variable to my instance.

       

      Map<String, Object> variables = new HashMap<String, Object>();
                variables.put("dataEntity", dataEntity);
                ProcessInstance instance = processEngine.getExecutionService()
                          .startProcessInstanceByKey("dataEntityProcess", variables);
      

       

      The converter gets triggered and the variable is converted to a Long.

      In my process I have a java task:

      <java name="activateAccount" expr="#{dataEntityProcessDAO}" method="activate">
                <arg>
                     <object expr="#{dataEntity}" />
                </arg>
                <transition to="end" />
           </java>
      

      As soon as my process reaches the task I get

      org.jbpm.pvm.internal.wire.WireException: method activate(java.lang.Long) is not available on object com.hre.portaldb.crosscommon.base.processes.DataEntityProcessDAOImpl@40b11a9f (com.hre.portaldb.crosscommon.base.processes.DataEntityProcessDAOImpl)
           at org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor.invokeMethod(ObjectDescriptor.java:206)
           at org.jbpm.jpdl.internal.activity.JavaActivity.perform(JavaActivity.java:76)
      

       

      The revert method of my converter is never called and it tries to use the Long on the method that takes DataEntity as input.

      What am I doing wrong?

       

      Thx

      Jochen

        • 1. Re: Converting a variable back
          jochen_mader

          I dug in a little deeper and found out that my variables generally don't get reverted.

           

          calling:

          engine.getExecutionService().getVariable(exec.getId(), "dataEntity")
          

           

          Just gives me a long and doesn't trigger revert on the converter.

           

          Is variable conversion a one way road?

           

          Thx,

           

          Jochen

          • 2. Re: Converting a variable back
            jochen_mader

            Solved it.

            looks like the documentation is lacking a little.

            To actually use the converter one needs to edit

            jbpm.execution.hbm.xml and add the converter to the converter typedef.

            Pretty hard to figure out and probably woth adding it to the docs.

             

              <!-- ### TYPEDEFS ####################################################### -->
              <typedef name="converter" class="org.jbpm.pvm.internal.hibernate.ConverterType">
                <param name="org.jbpm.pvm.internal.type.converter.BooleanToStringConverter"    >bool-str</param>
                <param name="org.jbpm.pvm.internal.type.converter.ByteToLongConverter"         >byte-long</param>
                <param name="org.jbpm.pvm.internal.type.converter.CharacterToStringConverter"  >char-str</param>
                <param name="org.jbpm.pvm.internal.type.converter.DateToLongConverter"         >date-long</param>
                <param name="org.jbpm.pvm.internal.type.converter.DateToStringConverter"       >date-str</param>
                <param name="org.jbpm.pvm.internal.type.converter.DoubleToStringConverter"     >double-str</param>
                <param name="org.jbpm.pvm.internal.type.converter.FloatToDoubleConverter"      >float-double</param>
                <param name="org.jbpm.pvm.internal.type.converter.FloatToStringConverter"      >float-str</param>
                <param name="org.jbpm.pvm.internal.type.converter.IntegerToLongConverter"      >int-long</param>
                <param name="org.jbpm.pvm.internal.type.converter.SerializableToBytesConverter">ser-bytes</param>
                <param name="org.jbpm.pvm.internal.type.converter.ShortToLongConverter"        >short-long</param>
                <param name="com.hre.portaldb.crosscommon.base.internal.DataEntityToLongConverter">dataEntity-long</param>
              </typedef>
            
            • 3. Re: Converting a variable back
              kukeltje

              Pretty hard to figure out and probably woth adding it to the docs.

              :-) This part of jBPM is afaik not officially 'stable' and so not realy in the docs yet, but you might want to create a jira issue and e.g. 'document adding custom converters' so it will not be forgotten at a certain (yet unspecified) moment in time.

               

              But great you got it working and thanks for reporting back. Might indeed be helpful to others.

              • 4. Re: Converting a variable back
                jochen_mader

                Sorry for the delay.

                I opened a feature request https://jira.jboss.org/jira/browse/JBPM-2821.

                 

                Thx,

                 

                Jochen