AnsweredAssumed Answered

How to convert Javascript Date in Java Date? (In Workflow)

Question asked by arak on Jun 20, 2014
Latest reply on Jun 24, 2014 by arak
Hi everyone,

I have a workflow with three task which share a field date for each task (task1 have date1, task2 have date1 and date2, and task3 have date1, date2 and date3). This dates is entered in the task and after copied in the metadata of document of the workflow (after of complete the task). But, in the moment which I complete the task, shoot the next error:

org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: Couldn't serialize value 'org.mozilla.javascript.NativeJavaObject@1c5d986a' in variable 'bcwf_fechaEnvio'

I know which one of the errors of the Rhino JavaScript integration in Alfresco, and I know I should convert the value to a standard Java date before setVariableLocal. Actually, I try this:

I create a java class for use in the taskListener (Create) of the task, whith this:


ActivitiScriptNode scriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package");
NativeArray children = (NativeArray) scriptNode.getChildren();
ScriptNode firstChild = (ScriptNode)children.get(0, null);
Map<String, Object> props = firstChild.getProperties();

String jsDate=props.get("{http://www.empresa.cl/wfmodel/content/1.0}fechaEnvio").toString();
System.out.println("Fecha Javascript: "+jsDate);
try {
   Date javaDate = new SimpleDateFormat("yy-MM-dd HH:mm:ss").parse(jsDate);
   System.out.println("Funciono :D, la fecha queda asi: "+javaDate);
} catch (ParseException e) {
   // TODO Auto-generated catch block
   System.out.println("No funciono :(");
   e.printStackTrace();
}


But the value of jsDate is "org.mozilla.javascript.NativeJavaObject@3f9cfb5", ¿Can I extract the date value of this object? ¿How to? ¿Some other way?

I create another java class for use in the taskListener (Complete) of the task for copy the value of form task into document, whith this:


ActivitiScriptNode scriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package");
NativeArray children = (NativeArray) scriptNode.getChildren();
ScriptNode firstChild = (ScriptNode)children.get(0, null);
      
firstChild.addAspect("bcwf:infoCalidad");


But, I don't know how to update the properties of the aspect in Java.

¿Any recommend? ¿Some guidance?

Thanks for any help.

Greetings,
Pablo.

Outcomes