0 Replies Latest reply on Aug 16, 2016 1:24 PM by abullor

    Marshalling / Unmarshalling process instance variables

    abullor

      Hi!

       

      I'm trying to start a process with a java.util.Date variable. I build the cliente like this:

       

      System.setProperty(KieServerConstants.CFG_BYPASS_AUTH_USER, "true");

      KieServicesConfiguration conf = KieServicesFactory.newRestConfiguration("http://localhost:8080/kie-server/services/rest/server", "myUser", "myPassword1!"); 

      conf.setMarshallingFormat(MarshallingFormat.JSON);

             

      Set<Class<?>> extraClasses = new HashSet<Class<?>>();

      extraClasses.add(Date.class); // for JSON only to properly map dates

      conf.addJaxbClasses(extraClasses);

      KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(conf);


      After that, I create the instance in this way:


      Map<String,Object> variables = new HashMap<String,Object>();

      variables.put("actorId", "9023");

      variables.put("myDate", new Date());

       

      ProcessServicesClient psc = this.kieServicesClient.getServicesClient(ProcessServicesClient.class);

      Long instanceId = psc.startProcess("myContainer", "myProcessId", variables);


      I put a sysout of the variables in a script task, and it writes:


      12:17:27,956 INFO  [stdout] (Thread-345 (HornetQ-client-global-threads-1235425573)) The variables are [{myDate=Tue Aug 16 12:17:22 ART 2016, actorId=9023}].


      So, myDate is a correct java.util.Date.


      But, if I try this from the same client:


      Map<String,Object> map = psc.getProcessInstanceVariables("myContainer", instanceId);

      System.out.println(map);


      {myDate=1471360642549, actorId=9023}

       

      myDate seems like a Long...

       

      Am I using the client in a wrong way?

       

      Thanks to all!!!