Page 1 of 1

How to call a java class in my workflow?

PostPosted:Tue Dec 03, 2019 4:40 pm
by kouadio
I created a java class WorkflowLogger according to the following tutorial. In my workflow, being in Eclipse, I do not know how to call the com.openkm.workflow.Workflow.java program so that it can save the workflow information in the database.
I find that it is neither ActionHandler nor TackHandler nor AssignmentHandler.
I remember that I am a novice and I use the virtual machine preinstalled.
Thank you for your help.

Re: How to call a java class in my workflow?

PostPosted:Thu Dec 05, 2019 5:43 pm
by jllort
You should watch at least all the videos from this point https://docs.openkm.com/kcenter/view/wf ... ourse.html
In the OpenKM development environment you have the almost samples shown in the videos, check them, there sure the OpenKM API classes are used. Basically you will find them in ActionHandlers is the most common place to use them.

Re: How to call a java class in my workflow?

PostPosted:Wed Dec 11, 2019 2:08 pm
by kouadio
Hi,
Thank you for assistance.
When I call my java class procedure (<action name"save" class="com.openkm.workflow.WorkflowLogger"></action>), here is the error I get in my file catalinat.log:
Code: Select all
GRAVE [http-nio-0.0.0.0-8080-exec-10] org.jbpm.instantiation.Delegation.instantiate couldn't instantiate delegation class 'com.openkm.workflow.WorkflowLogger'
 java.lang.NullPointerException
Thank you for helping me

Re: How to call a java class in my workflow?

PostPosted:Fri Dec 13, 2019 4:21 pm
by jllort
Did you created the WorkflowLogger.java class ? because in the code of OpenKM does not exist
Did you acced in the project ( into the par file the class exist, did you added in the same panel you add forms ). The par file is a zip file ( renamed )

Re: How to call a java class in my workflow?

PostPosted:Tue Feb 25, 2020 4:17 pm
by kouadio
After downloading another version of "Community development environment", the workflow ran without incident. However, I do not know where the data is stored. I look in the OKM_DB_METADATA_VALUE and OKM_DB_METADATA_TYPE tables but nothing, no data.

Re: How to call a java class in my workflow?

PostPosted:Sat Feb 29, 2020 4:30 pm
by jllort
What kind of data ? the workflow data is stored into JBPM_* tables

Re: How to call a java class in my workflow?

PostPosted:Mon Mar 02, 2020 5:45 pm
by kouadio
I want the data from my form that was populated in my workflow journey. Here is an extract from my forms.xml file and in attached file a screenshot of the user page and the summary of the data in the administration screen of the workflow. In fact, this is the information I want, but I can't find it in any table in my database.
Code: Select all
<workflow-form task="avis favorable">
    <input label="Date" name="date" data="date" readonly="true" />
    <input name="direction" label="Direction" data="direction" readonly="true"/>
    <input name="Responsable" label="Responsable hiérarchique" data="Responsable" readonly="true"/>
    <input name="Ordonnateur" label="Ordonnateur" data="Ordonnateur" readonly="true"/>
    
    <checkbox name="budgetise" label="budgetise" data="budgetise" readonly="true"/>
    <checkbox name="non budgetise" label="non budgetise" data="non budgetise" readonly="true"/>
    <input label="Designation" name="Designation" data="Designation" readonly="true" />
	
    <input label="Quantite" name="quantite" data="quantite" readonly="true" />
    <input label="Prix unitaire" name="Prix unitaire" data="Prix unitaire" readonly="true" />
    <input label="Montant total TTC" name="Montant total TTC" data="Montant total TTC" readonly="true" />
    
    <textarea label="Observations" name="observations" data="observations" readonly="true" />
    <input label="Avis responsable supérieur" name="responsable" data="responsable" readonly="true" />
    <input label="Avis controle de gestion" name="cgai" data="cgai" readonly="true" />
    <input label="Avis DAF" name="daf" data="daf" readonly="true" />
    <button name="Terminer" label="Terminer" transition="terminer"/>
</workflow-form>

Re: How to call a java class in my workflow?

PostPosted:Sat Mar 07, 2020 10:47 am
by jllort
You must collect the data in the form during the workflow transaction and store as metadata. The workflow will not make it automatically do it for you, it is something you must control in your side ( workflow form elements does not have a direct mapping to metadata, because maybe you are interested in mapping single workflow form into several metadata groups )

Re: How to call a java class in my workflow?

PostPosted:Mon Mar 09, 2020 9:01 am
by kouadio
Thank you for your concise answer. But how do I do the mapping?

Re: How to call a java class in my workflow?

PostPosted:Fri Mar 13, 2020 8:24 am
by jllort
Is a manual mapping. You got the values in the transaction ( are stored in the context ). Must get the data and store as metadata.

Take a look here https://docs.openkm.com/kcenter/view/wf ... -node.html in your case into the vars are objects of type Input, Select ( FormElements ).

Here the code to import metadata https://docs.openkm.com/kcenter/view/ok ... tiesSimple

Re: How to call a java class in my workflow?

PostPosted:Wed Mar 18, 2020 5:22 pm
by kouadio
I tell you I'm really null in java. In accordance with your recommendations, here is my configuration which does not work. Really, I don't know how to solve my problem.
Code: Select all
package com.openkm.workflow.ged;

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

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ISO8601;
public class metadonneesinsert implements ActionHandler {

	 /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static void main(String[] args) {
        try {                                           
            Map<String, String> properties = new HashMap<>();
            properties.put("okp:BonCommande.direction", "new direction");
            properties.put("okp:BonCommande.civilite", "new civilite");
            properties.put("okp:BonCommande.Ordonnateur", "new Ordonnateur");
            properties.put("okp:BonCommande.document", "new document");
            properties.put("okp:BonCommande.justificatif", "new justificatif");
            properties.put("okp:BonCommande.description", "new description");
            properties.put("okp:BonCommande.duree", "new duree");
            properties.put("okp:BonCommande.observations", "new observations");
            properties.put("okp:BonCommande.avisarchiviste", "new avisarchiviste");
            
            // Date fields must be saved with basic ISO 8601 format
            properties.put("okp:BonCommande.date", ISO8601.formatBasic(Calendar.getInstance()));
            OKMPropertyGroup.getInstance().setPropertiesSimple(null, "/okm:root/logo.pdf","okg:BonCommande", properties);           
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

	@Override
	public void execute(ExecutionContext arg0) throws Exception {
		// TODO Auto-generated method stub
	}
}

Re: How to call a java class in my workflow?

PostPosted:Sun Mar 22, 2020 11:35 am
by jllort
Try with the code below:
package com.openkm.workflow.ged;
Code: Select all
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ISO8601;
public class metadonneesinsert implements ActionHandler {
 private static final long serialVersionUID = 1 L;


 @Override
 public void execute(ExecutionContext arg0) throws Exception {
  try {
   Map < String, String > properties = new HashMap < > ();
   properties.put("okp:BonCommande.direction", "new direction");
   properties.put("okp:BonCommande.civilite", "new civilite");
   properties.put("okp:BonCommande.Ordonnateur", "new Ordonnateur");
   properties.put("okp:BonCommande.document", "new document");
   properties.put("okp:BonCommande.justificatif", "new justificatif");
   properties.put("okp:BonCommande.description", "new description");
   properties.put("okp:BonCommande.duree", "new duree");
   properties.put("okp:BonCommande.observations", "new observations");
   properties.put("okp:BonCommande.avisarchiviste", "new avisarchiviste");

   // Date fields must be saved with basic ISO 8601 format
   properties.put("okp:BonCommande.date", ISO8601.formatBasic(Calendar.getInstance()));
   OKMPropertyGroup.getInstance().setPropertiesSimple(null, "/okm:root/logo.pdf", "okg:BonCommande", properties);
  } catch (Exception e) {
   e.printStackT
  }
 }
Consider to play with JAVA in OpenKM you should have at least 3 years of expertice.

Re: How to call a java class in my workflow?

PostPosted:Tue Mar 24, 2020 1:09 pm
by kouadio
When I copy and paste the code in eclipse window, I get three (03) errors as shown in the image below:

Re: How to call a java class in my workflow?

PostPosted:Fri Mar 27, 2020 8:59 am
by jllort
Sorry, but sincerely if you are not able to solve these errors yourself you do not have minimal knowledge to play with the JAVA workflows. I thin you have 2 options:
1- try to find somebody more skilled with JAVA
2- in the forum were freelance people what might help you on it ( viewtopic.php?f=5&t=23156&p=49549&hilit=saul#p49549 )